Wednesday 27 January 2016

write a program in java to count how many vowels present in a sentence without using build in function.

Code:
class Vowel_ASCII
{
  public static void main(String args[])
  {
    String st="THIS IS IT";
    int i,l,c,count=0;
    l=st.length();
    for(i=0;i<l;i++)
    {
      c=st.charAt(i);
      if(c==65 || c==69 || c==73 || c==79 || c==85 ||
         c==97 || c==101 || c==105 || c==111 || c==117)
         count++;
    }
    System.out.println(count);
  }
}

No comments:

Post a Comment