165k views
0 votes
g Write a C program that prompts the user for a string of, up to 50, characters and numbers. It can accept white spaces and tabs and end with a return. The program should keep track of the number of different vowels (a,e, i, o, u) and the number of digits (0, 1, 2, 3, 4, 5, 6, 7, 8,9). The program should output the number of occurrences of each vowel and the number of occurrences of all digits.

User Smriti
by
4.7k points

1 Answer

2 votes

Answer:

Following are the code to this question:

#include <stdio.h> //defining header file

#include <string.h>//defining header file

int main()//defining main method

{

char name[50]; //defining character variable

int A=0,E=0,I=0,O=0,U=0,value=0,i,l; //defining integer variables

printf("Enter string value: ");//print message

gets(name);//input value by gets method

l=strlen(name);//defining l variable to store string length

for(i=0; i<50; i++) //defining loop to count vowels value

printf("A: %d\\",A);//print A value

printf("E: %d\\",E); //print E value

printf("I: %d\\",I);//print I value

printf("O: %d\\",O);//print O value

printf("U: %d\\",U);//print U value

printf("value: %d",value);//print digits value

return 0;

}

Output:

please find the attachment.

Step-by-step explanation:

  • In the above code, a char array "name" and integer variables "A, E, I, O, U, i, value and l" declared, in which name array store 50 character value, which uses the gets function to take string value.after input value strlen method is used to store the length of the input string in l variable.
  • In the next step, for loop is declared that uses multiple conditional statements to counts vowels and the values of the digits,if it is more then one it increments its value and at the last print method is used to print its count's value.
g Write a C program that prompts the user for a string of, up to 50, characters and-example-1
User Andrew Porritt
by
5.1k points