Author Topic: Turbo C Program for displaying number of Vowels in a line  (Read 1480 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Turbo C Program for displaying number of Vowels in a line
« on: February 21, 2012, 12:09:17 pm »
Here is the Turbo C Program for displaying number of Vowels in a line:


Code:
//Source Code Listing

#include <stdio.h>
#include <string.h>

void main()
{
   int i, j, len;
   int count = 0;
   int isVowel = 0;
   char buffer[512];
   static char v[] = { 'a', 'e', 'i', 'o', 'u',
                       'A', 'E', 'I', 'O', 'U',
                     };
   printf("Enter a String: ");
   gets(buffer);

   len = strlen(buffer);

   for(i = 0; i < len; i++)
   {
      isVowel = 0;
      for(j = 0; j < sizeof(v) / sizeof(v[0]); j++)
      {
         if(buffer[i] == v[j])
         {
            isVowel = 1;
            break;
         }
      }
      if(isVowel == 1)
         count++;
   }
   printf("\nNumber of vowels in the given string is: %d", count);
   getch();
   return;
   
}

Output:

Enter a String: www.softwareandfinance.com
Number of vowels in the given string is: 8

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1