google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to count vowels and consonants in a string - 2nd puc computer science

Write a c program to count vowels and consonants in a string

write a c program to count vowels and consonants in a string,write a program to count the number of vowels and consonants in a string,vowels and consonants in c program

Write a c program to count vowels and consonants in a string

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

char s[50];

int l,i,cons=0,vow=0;

clrscr();

printf("Enter your name: ");

gets(s);

l=strlen(s);

for(i=0;i<l;i++)

if(isalpha(s[i]))

         switch(toupper(s[i]))

         {

                  case 'A':

                  case 'E':

                  case 'I':

                  case 'O':

                  case 'U': vow++;

                           break;

                  default: cons++;

         }

printf("Number of vowels in your name=%d\n",vow);

printf("Number of consonants in your name=%d",cons);

getch();

}

Output:

Enter your name: Hanumanth

Number of vowels in your name=3                                                

Number of consonants in your name=6                                            


Write a c program to count vowels and consonants in a string Write a c program to count vowels and consonants in a string Reviewed by Vision Academy on December 13, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.