Using C programming, write a program that gets a list of words from the user as input and outputs the largest and the smallest word provided. Your solution also must output the number of vowels in both words. You must use functions in your code
• TEST YOUR CODE WITH THIS, type 10 countries from the list below as input:[Argentina, Australia, Brazil, Canada, China, France, Germany, India, Indonesia, Italy, Japan, Republic of Korea, Mexico, Russia, Saudi Arabia, South Africa, Turkey, UK, USA, UK]
The program is printing the largest word and the smallest word properly and i've used functions as well
I've also added the number of vowels but the only problem is when I run the code it prints the largest word and then the number of vowels of the largest word. But when it comes to the smallest word it basically prints the same number of vowels as the largest word.
#include
#include
/*GLOBAL METHOD DECLARATION*/
int vowels(char []);
int check_vowels(char);
int main()
{
/*LINE 11 TO LINE 20 ARE USED TO DELCARE MY VARIABLES*/
int i=0;
int j=0;
int k=0;
int a;
int minIndex=0;
int maxIndex=0;
int max=0;
int min=0;
char countries[100],lswords[100][100];
int vc;
printf("**********WORD LENGTH AND VOWELS COUNTER**********\n");
printf("\n***THIS PROGRAM GETS A LIST OF WORDS FROM THE USER AS INPUT AND,\n");
printf("OUTPUTS THE LARGEST AND THE SMALLEST WORD PROVIDED");
printf("\nYOUR PROGRAM ALSO MUST OUTPUT THE NUMBER OF VOWELS IN BOTH WORDS\n");
printf("\n\tHERE'S A LIST OF 10 COUNTRIES:\n\t");
printf("\n\tARGENTINA,AUSTRALIA, BRAZIL, CANADA, CHINA, FRANCE, GERMANY, INDIA, INDONESIA, ITALY,\n\t");
printf("\n\tJAPAN, REPUBLIC OF KOREA, MEXICO, RUSSIA, SAUDI ARABIA, SOUTH AFRICA, TURKEY, UK, USA\n\t");
printf("\nENTER 10 COUNTRIES FROM THE LIST ABOVE AS AN EXAMPLE OF AN INPUT:\n");
printf("\n");
gets(countries); /*THIS ALLOWS THE USER TO INPUT A STRING AND STORES THE DATA IN COUNTRIES*/
while(countries[k]!='\0') /*THIS IS USED TO SPLIT THE SENTENCES*/
{
j=0;
while(countries[k]!=' '&&countries[k]!='\0')
{
lswords[i][j]=countries[k];
k++;
j++;
}
lswords[i][j]='\0';
i++;
if(countries[k]!='\0')
{
k++;
}
}
int len=i;
max=strlen(lswords[0]);
min=strlen(lswords[0]);
/*LINE 60 TO 72 IS USED AFTER SPLITTING THE LENGTH OF STRING*/
/*AND FINDING ITS INDEX USING MAX LENGTH AND MIN LENGTH*/
for(i=0;i max)
{
max=a;
maxIndex=i;
}
if(a = 'A' && lswords<='Z')
/*IT WOULD CONVERT THE LOWERCASE USING THE ASCII VALUES*/
lswords = lswords+'a' - 'A';
/*IF THE CHAR IS ANY OF THE VOWEL STATED*/
if(lswords == 'a' || lswords=='e' || lswords=='i' || lswords =='o' || lswords== 'u')
return 1; /*THIS WOULD MAKE THE FLAG EQUAL TO 1*/
return 0; /*IF THERE'S NO VOWELS, THEN THE FLAG REMAIN 0*/
}
Answers
Answered by
1
Answer:
follow me
i know c program today evening i will post it for you so follow me
Similar questions
English,
4 months ago
Math,
4 months ago
Computer Science,
4 months ago
Math,
8 months ago
History,
8 months ago