+ 1
Read a line of characters from keyboard, if it is a lowercase letter, output its uppercase equivalent, and vice versa.
5 ответов
+ 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
+ 2
Eve Where is your try?
+ 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);
}
0
Hope someone to help me.
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;
}