** Topics requirements: ** enter a character, to determine whether it is a capital letter, if there is to convert it to lower case, and if not, not conversion. Then output the resulting character.
** Topic Analysis: ** can be used if ... else statement or conditional expression
Code 1 (if ... else)
#include "stdio.h"
void main()
{
char ch;
scanf("%c",&ch);
if(ch>=65&&ch<=90)//这一步也可以为 if(ch>='A'&&ch<='Z')
{
ch=ch+32;
printf("%c",ch);
}
else
printf("%c",ch);
}
Code 2 conditional expression
#include "stdio.h"
void main()
{
char ch;
scanf("%c",&ch);
(ch>='A'&&ch<='Z')?(ch=ch+32):ch;
printf("%c",ch);
}
Summary :
After 1.if with only one statement, if there are many use the {} bracketed
2. Conditional Expressions "12:? 3" Usage is established if 1 2 is performed not established three execution
3.char type input and output use C%
4. in this problem the same code value used in ascll ascll code values differ between the case of letters 32 here linked to the code table ascll