Converts uppercase and lowercase letters to uppercase and lowercase letters.

Source: Internet
Author: User

Converts uppercase and lowercase letters to uppercase and lowercase letters.

// Kailu garji-blog Park Co., http://www.cnblogs.com/kailugaji/.

Method 1:

1 # include <stdio. h> 
2 # include <stdlib. h> 
3 // 32-bit 
4 void main () {
5 char ch, t; 
6 printf ("Please input a letter: \ n "); 
7 ch = getchar (); 
8 t = getchar (); // absorb the Enter key 
9 
10 while (ch <'A' & ch> 'Z ') | (ch <'Z' & ch> 'A') {
11 printf ("Input error! \ NPlease input again: \ n "); 
12 ch = getchar (); 
13} 
14 
15 if (ch & 32) 
16 ch = ch & 223; // change the fifth digit to 0 and the fifth digit to 
17 else ch = ch | 32; // reduce the fifth digit to 1 and write 
18 
19 putchar (ch ); 
20 printf ("\ n"); 
21}

Method 2:

1 # include <stdio. h> 
2 # include <stdlib. h> 
3 // 32-bit 
4 void main () {
5 char ch; 
6 printf ("Please input a letter: \ n "); 
7 scanf ("% c", & ch); 
8 ch = (ch> = 'A' & ch <= 'Z ')? (Ch + 32) :( (ch> = 'A' & ch <= 'Z ')? (Ch-32): printf ("Input error! "); 
9 printf (" % c \ n ", ch); 
10}

Result:






 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.