----------------------------------------------------------------------------------------
//Single Judgmentif(A <0) {printf ("less than 0");}//Elseif(A <0) {printf ("less than 0");} Else{printf ("not less than 0");}//If nestingif(A <0) {if(A <-5) {printf ("less than-5"); } Else{printf ("no less than-5"); }} Else{printf ("greater than 0");}//cascading if else ifif(A <0) {printf ("less than 0");} Else if(A <-5) {printf ("less than-5");} Else if(A <-Ten) {printf ("less than -10");} Else{printf ("not less than 0");}//cascading if else if another notation (recommended notation: Single exit)intSign =0;if(A <0) {T= -1;} Else if(A <-5) {T= -6;} Else if(A <-Ten) {T= - One;} Else{T=1;} printf ("%d", T);//Multi-Channel branchSwitch(a) { Case 1: printf ("1"); Break; Case 2: printf ("2"); Break; default: printf (" Other");}
Tips:1. Do not omit curly braces;
2. The assignment operator and the equality operator are careful not to use errors when judging
+ + with--
#include <stdio.h>intMain () {intA; A=2; printf ("a++=%d \ n", a++); 2 printf ("%d \ n", a); 3 printf ("++a=%d \ n", ++a); 4 printf ("%d \ n", a); 4return 0;}
Note: either a++ or ++a, the last value of a is a+1, the difference is that a++ is an expression, the result is the result of a+1, and the result of ++a is a+1 as a prefix.
While vs. do. While
intA =0; scanf ("Enter a number:%d", &a); while(A >0) {printf ("a"); A--;} printf ("a"); Do{printf ("a"); A--;} while(A >0);
Link:http://www.cnblogs.com/farwish/p/4172901.html
@ Black eyed poet <www.chenwei.ws>
[C language] Process control, compound assignment, loop