C language uppercase and lowercase letters conversion

Source: Internet
Author: User

Kerugaki-Blog Park http://www.cnblogs.com/kailugaji/

Method 1:

1#include <stdio.h>2#include <stdlib.h>3 //uppercase and lowercase letters separated by 32 digits4 voidMain () {5     Charch,t;6printf"Please input a letter:\n");7Ch=GetChar ();8T=getchar ();//Absorbing Enter9 Ten      while((ch<'A'&& ch>'Z') || (ch<'Z'&& ch>'a')){ Oneprintf"input Error!\nplease input again:\n"); ACh=GetChar (); -     } -  the     if(Ch & +) -Ch=ch &223;//make fifth bit 0, capitalize -     ElseCh=ch | +;//make fifth bit 1, lowercase -  + Putchar (CH); -printf"\ n"); +}

Method 2:

1#include <stdio.h>2#include <stdlib.h>3 //uppercase and lowercase letters separated by 32 digits4 voidMain () {5     Charch;6printf"Please input a letter:\n");7scanf"%c",&ch);8Ch= (ch>='A'&& ch<='Z')? (ch+ +):((ch>='a'&& ch<='Z')? (ch- +):p rintf ("Input error!"));9printf"%c\n", ch);Ten}

The result is:

C language uppercase and lowercase letters conversion

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.