Canna

Saturday, 15 June 2019

NUMBER OF VOWELS AND CONSTANT

  • Problem Description

    Count vowels and constants in a given string using pointers
  • Test Case 1

    Input (stdin)
    welcome
    
    
    Expected Output
    3 4
  • Test Case 2

    Input (stdin)
    hello
    
    
    Expected Output
    2 3
  • Program
  • #include <stdio.h>
    int main()
    {
      char str[20];
      char *ptr;
      int cntV;
      int cntC;
     scanf("%s",str);
      ptr=str;
      cntV=cntC=0;
      while(*ptr!='\0')
        {
        if(*ptr=='a'||*ptr=='e'||*ptr=='i'||*ptr=='o'||*ptr=='u')
          cntV++;
          else
            cntC++;
      ptr++;
        }
      printf("%d %d\n",cntV,cntC);
    
      
      
          
        
    
      
    
     return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.