Program to calculate the number of vowels

Tuesday, August 11, 2020

//Program to calculate the number of vowels

#include<iostream.h>

#include<conio.h>

#include<stdio.h>

#include <ctype.h>

void CHARTYPE(char STRING[20]);

void main ()

{clrscr();

char string[20],ch;

cout<<"\n Enter a string:";

gets(string);

CHARTYPE(string);

getch();

}

void CHARTYPE(char string[20])

{char ch;

 int len,v=0,c=0,o=0,d=0;

 for(len=0;string[len]!='\0';++len)

 {if(isalpha (string[len]))

  {ch=toupper(string[len]);

   if(ch=='A'||ch=='E'||ch=='I'||ch=='0'||ch=='U')

   ++v;

   else

   ++c ;

  }

else if (isdigit (string[len]))

++d;

else

++o;

}

cout<<"\n There are "<<v<<"vowels,"<<c<<"constants,"<<d<<"digit and"<<o<<"other character in the given string :";

}

You Might Also Like

0 Comments

Like us on Facebook

Flickr Images

Flickr Short Films