/* 2. programming questions
1) input a string from the keyboard, and change the upper-case letters to lower-case letters, lower-case letters to upper-case letters, and output.
[Requirement]
(1) Use a character array to store strings (the maximum value of a string is 100 ).
(2) Use the scanf function to input characters one by one and save them in the character array.
(3) Use the printf function to output characters in the character array one by one
*/
The question is simple, but the scanf function is required to input characters one by one and store them in the character array, which is difficult for beginners.
# Include <stdio. h>
Void main ()
{
Int I = 0;
Char A [100], C;
Printf ("Enter the string content: \ t ");
Do {
Scanf ("% C", & A [I]);
C = A [I];
I ++;
} While (C! = '\ N ');
A [I] = '\ 0 ';
I = 0;
Printf ("input string content: \ t ");
While (A [I]! = '\ 0 ')
{
Printf ("% C", a [I]);
I ++;
}
Printf ("converted string content: \ t ");
I = 0;
While (A [I]! = '\ 0 ')
{
C = A [I];
If (C> = 'A' & C <= 'Z ')
A [I]-= 32;
Else if (C> = 'A' & C <= 'Z ')
A [I] + = 32;
Printf ("% C", a [I]);
I ++;
}
}