Tuesday, 26 March 2019

CP : count the vowels in string

Que: Write a program to count the number of vowels in a given string

Vowels : a,e,i,o,u 

Code: 

#include <stdio.h>
int main()

{
  int c = 0, count = 0;
  char s[1000];

  printf("\nInput a string\n");
  gets(s);

  while (s[c] != '\0')
 {
    if (s[c] == 'a' || s[c] == 'A' || s[c] == 'e' || s[c] == 'E' || s[c] == 'i' || s[c] == 'I' || s[c] =='o' || s[c]=='O' || s[c] ==                       'u' || s[c] == 'U')
      count++;
    c++;
  }

  printf("\nNumber of vowels in the string: %d\n", count);

  return 0;
}


Output:


No comments:

Post a Comment

LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project

  LAB 7 Arduino with Seven Segment Display || Arduino Tutorial || Code and Circuit Diagram || Project Dear All We will learn how to Connec...