iOS Learning Notes---C language the next day

Source: Internet
Author: User

One, bool Boolean type C language does not have bool type, OC has bool type

is a non-true-and-false data type, with a Boolean type of variable that has only Yes and no two values. Yes indicates that the expression is true and no indicates that the expression is false.

In the C language, it is true that 0 is not.

The bool value is commonly used in branch statements to determine whether an if statement or an else statement is executed.

In a cyclic structure, it is also often used to determine whether a loop is to be executed using the BOOL value.

Precautions:

#define YES 1

#define NO 0

When the computer is recognized, yes is replaced by 1,no instead of 0.

Second, relational operators

> >= <= = = =!

Mainly used for comparison operation, the result of comparison is only true and false two cases, the result value is stored with BOOL type variable.

Note: Determine whether two numbers are equal with = = (double equals).

#import <Foundation/Foundation.h>

int Main (int argc, const Char * argv[])

{

BOOL A = 3 >6;

printf ("a =%d", a);

return 0;

}

BOOL can be seen as a smaller range of shaping, with only two numbers of 1 and 0.

Third, logical operators

An expression consisting of logical operators, and the result is not true or false

&& (Logic and): The result of the entire logical expression is true when the expression on both sides of the operator is true.

|| (logical OR): When the expression on both sides of the operator is false, the result of the entire logical expression is false. An expression | | An expression

! (logical): Reverse the result of an expression.

Short Circuit phenomenon

&& the front is false, the back is not calculated directly to determine the false

Attention to logic and logic or short circuit phenomena

&&------A fake or fake

|| -------is True

Three structures of the program: sequential structure, branching structure, cyclic structure

Iv. If statement

Constructs a branching structure with an if statement, which determines the execution of a branch segment based on the conditions given.

The expression form of the IF statement in C language

1.if (conditional expression) {

Statement 1;

}

When the conditional expression is true, execute statement 1, otherwise skip statement 1 and proceed to the following statement.

eg

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.