Programing course,, Write a program that gets a set of characters from the user
ID: 2249989 • Letter: P
Question
Programing course,, Write a program that gets a set of characters from the user and stores them in an array chars ]. The program stops when the number of characters is greater than 10 or ## is entered, whichever comes first. Then the program performs the following tasks: 1. Displays the array using a user defined function that has the following prototype void dispArray(char x[], int N); 2. Computes the count of vowels (lower or upper cases) using a user-defined function named findSum Vols 0 with the following prototype int findNumVols (char x[], int N); In addition, this function calls another user-defined function named isVowel() to check each element of its input array if it is vowel or not. The function isVowel returns 1 if its input is a vowel character and 0 otherwise and has the following prototype: int isVowel(char ch);Explanation / Answer
#include<stdio.h>
void dispArray(char x[10], int i);
int findSumVols(char x[10], int i);
int isVowel(char ch);
main()
{
char x[10],ch;
int i,k,j;
for(i=0;i<10;i++){
scanf("%s",&x[i]);
if (x[i]=='##')
break;
}
dispArray(x,i);
findSumVols(x,i);
for (k=0;k<i;k++){
ch=x[k];
j=isVowel(ch);
}
}
void dispArray(char a[10],int i){
int k;
printf("string: ");
for (k=0;k<10;k++)
printf("%c",a[k]);
}
int findSumVols(char a[10], int i){
int b=0,k;
for (k=0;k<i;k++){
if (a[k]== 'a' || a[k]=='e' || a[k]=='i' || a[k]=='o' || a[k]=='u' || a[k]== 'A' || a[k]=='E' || a[k]=='I' || a[k]=='O' || a[k]=='U')
b++;
}
printf (" number of vowels = %d",b);
}
int isVowel(char ch){
if (ch== 'a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch== 'A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
return 1;
else
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.