C conditional expressions

Source: Internet
Author: User
Tags switch case

C conditional expressions
Today, I learned the C language expression. if it is else, if it is else, or else it actually means the above! Here is an example: if (age> = 18) // if the age variable value is greater than or equal to 18 {printf ("you are an adult ");} else if (age> 4) // if age is less than 18 but greater than 4 // it can be understood separately that else corresponds to the top if, if it corresponds to the last else {printf ("fortunately you are not too young");} else // if the age is less than or equal to 4 {printf ("mama, guagua... "); // language, do not understand the switch case statement: for example: switch (num) {case 1: printf (" I am #1 \ n "); break; case 2: printf ("I am #2 \ n"); break; case 3: printf ("I am #3 \ n"); break; default: printf ("num error \ n"); break; \ default should be placed behind the last case. If there is no break, the subsequent code will be executed, regardless of whether the subsequent case matches, until the next break is met. Note: The condition must be "=" and cannot be "= ", an equal sign is a value, not a judgment. <Less> greater than = equal to> = greater than or equal to <= less than or equal! = Not equal to & logical and "and" | logical or "or "! The logic is not "Opposite"

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.