How to write a C Program which can convert Volwels in the given string to lower if it were upper and upper if it were lower? -


#include <ctype.h> #include <stdio.h> #include <conio.h> int main(void) {     char input[50];     char i;     int j = 0;      printf("please enter sentence: ");     fgets(input, 50 , stdin);      (j = 0; input[i] != '\0'; j++)               if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u')         {             input[i]=toupper(input[i]);             printf("your new sentence is: %s", input);         }           else if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u')         {             input[i]=tolower(input[i]);             printf("your new sentence is: %s", input);         }      return 0; } 

this not home work .i beginner in c .i can not find out mistake in code have googled cant locate useful data correct mistake.the error getting printf("your new sentence is: %s", input);---->this line not performing action , appreciate if correct mistake.

input-please enter sentence beginner in c

desired output- new sentence is:i beginner in c

actual output - //empty line//

thanks

like other answer says, want use i, not j.... want put {} in for. move printf ....... make simpler extended exercise :)

for (i = 0; input[i] != '\0'; i++)       {         if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u')         {             input[i]=toupper(input[i]);         }           else if (input[i]=='a'||input[i]=='e'||input[i]=='i'||input[i]=='o'||input[i]=='u')         {             input[i]=tolower(input[i]);          } }    printf("your new sentence is: %s", input);     return 0; 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -