C language: No if,else statements, no loop conditions, etc., enter a character to determine whether it is an uppercase letter

Source: Internet
Author: User

Do not use if,Else statements, or loop conditions, and so on, enter a character, determine if it is an uppercase letter, or, if it is, convert it to lowercase; The last output is the resulting character.

Program:

#include <stdio.h>

int main ()

{

Char ch;

printf ("Please enter a character:");

scanf ("%c", &ch);

CH = (ch >= ' A ' &&ch <= ' Z ')? (CH + +): ch;

printf ("%c\n", ch);

return 0;

}

Result 1:

Please enter a character:B

B

Please press any key to continue ...

Result 2:

Please enter a character:a

A

Please press any key to continue ...


This article is from the "Rock Owl" blog, please be sure to keep this source http://yaoyaolx.blog.51cto.com/10732111/1741357

C language: No if,else statements, no loop conditions, etc., enter a character to determine whether it is an uppercase letter

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.