+ 1

Read a line of characters from keyboard, if it is a lowercase letter, output its uppercase equivalent, and vice versa.

29th Mar 2019, 10:24 AM
Eve
Eve - avatar
5 Respuestas
+ 5
1) You read two times without process the read in between 2) You will print only the last char because print call is outside the while loop
29th Mar 2019, 11:43 AM
KrOW
KrOW - avatar
+ 2
Eve Where is your try?
29th Mar 2019, 11:17 AM
KrOW
KrOW - avatar
+ 1
Sorry, its here. #include <stdio.h> void main() { char a ; while (( getchar())!='\n') { a=getchar (); if (a>='a'&&a<='z') { a-=32; } else if(a>='A'&&a<='Z') { a+=32; } } printf ("%c",a); }
29th Mar 2019, 11:20 AM
Eve
Eve - avatar
0
Hope someone to help me.
29th Mar 2019, 10:26 AM
Eve
Eve - avatar
0
This one can work effectively. #include <stdio.h> int main() { printf (" input characters:"); char a ; while ( a=getchar()) { if (a>='a'&&a<='z') a=a-32; else if(a>='A'&&a<='Z') a=a+32; putchar(a); } return 0; }
29th Mar 2019, 11:57 AM
Eve
Eve - avatar