by CodeChum Admin
Make me a program that accepts a size of the character array and its values. Then, count the number of uppercase vowels that are in it.
Easy, right? Then go and code as if your life depends on it!
Tip: After your scan for the size, add a space after the placeholder like this so that the newline character directly after the number won't be scanned as one of the characters:
scanf("%d ", &size);
Input
1. Size of the array
2. Characters of the array
Output
The first line will contain a message prompt to input the size of the array.
The second line will prompt to input the characters of the array.
The last line contains the count of the uppercase vowels.
Enter·the·size·of·the·array:·19
CodeChum·is·AWEsome
Count·=·2
#include <stdio.h>
int main(int argc, char *argv[])
{
int size, i;
int count = 0;
char ch;
printf("Enter the size of the array: ");
scanf("%d ", &size);
for (i = 0; i < size; i++)
{
scanf("%c", &ch);
if (ch == 'A' || ch == 'E' || ch == 'I'
|| ch == 'O' || ch == 'U')
count++;
}
printf("Count = %d", count);
return 0;
}
Comments
Leave a comment