#include <stdio.h>
int main() {
char c;
do {
scanf("%c", &c);
if (c >= 'A' && c <= 'Z') {
int letter=c+32;
printf("%c",letter);
}else if(c>='a' && c<='z'){
int letter=c-32;
printf("%c",letter);
}printf("%c",c);
}
} while (c != '.');
return 0;
}
This program reads characters one by one and attempts to change uppercase to lowercase and vice versa, but it prints each character twice and has a loop structure issue.
- The program prints the original character `c` after every conversion, so you see both the converted and original character for each input. Check where the second `printf("%c",c);` is placed and whether it should be there.
- The `do-while` loop has an extra closing brace before `while`, which will cause a compilation error. Look at the brace placement after the `else if` block to ensure the loop body is correctly enclosed.