Monday, July 31, 2017

Find no. of vowels in a string in C


#include<stdio.h>
void strcount(char []);
void main()
{
  char str[50];
  char c;
  while(1)
  {
    printf("enter string\n");
    //gets(str);
    scanf("%s",str);
    strcount(str);

    printf("want to run again? press y/n \n");
    scanf("%s",&c);
    if(c == 'n' || c == 'N')
        break;
  }
}
void strcount(char str[50])
{
int i,j=0;
for (i=0;str[i]!=NULL;i++)
 {
  if( str[i]=='a'||str[i]=='A'||str[i]=='e'||str[i]=='E'||str[i]=='i'||str[i]=='I'||str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U')
  j++;
 }
 printf("count of vowels in string is %d\n",j);
}

Related Posts:

  • Find fibonacci series in C#include<stdio.h> void fibonacci(int); void main() {     int n,first=0,second=1;     printf("Enter the number of fibonacci series to be printed : ");     scanf("%d",&n);     p… Read More
  • Find no. of vowels in a string in C #include<stdio.h> void strcount(char []); void main() {   char str[50];   char c;   while(1)   {     printf("enter string\n");     //gets(str);     scanf("%s",str); &nb… Read More
  • Application of struct in C#include<stdio.h> #include<string.h> struct student {     char name[20];     int roll; }; void main() {   struct student s[10],t;   int i,n,j;   printf("Enter no. of students : "… Read More
  • Find HCF in C#include<stdio.h> int hcf(int a,int b,int c) {     if(a%c==0 && b%c==0)     return c;     hcf(a,b,c-1); } void main() {     int h,x,y;     printf("Enter two numb… Read More
  • Check if a no. is prime or not in C ?#include<stdio.h> int testprime(int ,int); void main() {     int n,prime;     printf("Enter a positive number : ");     scanf("%d",&n);     prime=testprime(n,n/2);   &nbs… Read More

0 comments:

Post a Comment