in turboc++
--------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char string[100],sec;
int i,count=0; //initialization
printf("enter string\n");
gets(string);//accepts string
strlwr(string);//converts the string into lowercase
for(i=0;string[i]!='\0';i++)//loop execution till null character
{
if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
//condition testing for character/vowels
{
count++;//counting words
}
}
printf("total vowels=%d",count);// prints total vowels.
getch();
return 0;
}
----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
int main()
{
char string[100],sec;
int i,count=0; //initialization
printf("enter string\n");
gets(string);//accepts string
strlwr(string);//converts the string into lowercase
for(i=0;string[i]!='\0';i++)//loop execution till null character
{
if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
//condition testing for character/vowels
{
count++;//counting words
}
}
printf("total vowels=%d",count);// prints total vowels.
return 0;
}
--------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
char string[100],sec;
int i,count=0; //initialization
printf("enter string\n");
gets(string);//accepts string
strlwr(string);//converts the string into lowercase
for(i=0;string[i]!='\0';i++)//loop execution till null character
{
if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
//condition testing for character/vowels
{
count++;//counting words
}
}
printf("total vowels=%d",count);// prints total vowels.
getch();
return 0;
}
----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------------------
//program to count total vowels in a string.
#include <stdio.h>
#include<string.h>
int main()
{
char string[100],sec;
int i,count=0; //initialization
printf("enter string\n");
gets(string);//accepts string
strlwr(string);//converts the string into lowercase
for(i=0;string[i]!='\0';i++)//loop execution till null character
{
if(string[i]=='a' || string[i]=='e'|| string[i]=='i'|| string[i]=='o' ||string[i]=='u')
//condition testing for character/vowels
{
count++;//counting words
}
}
printf("total vowels=%d",count);// prints total vowels.
return 0;
}
No comments:
Post a Comment