This document is a quick reference cheat sheet for the C programming language, outlining the basic syntax and structure of a C program. It compares algorithmic language syntax with C language syntax, highlighting key elements such as variable declaration, operators, input/output statements, and control structures. The cheat sheet serves as a concise guide for understanding fundamental C programming concepts.
This document is a quick reference cheat sheet for the C programming language, outlining the basic syntax and structure of a C program. It compares algorithmic language syntax with C language syntax, highlighting key elements such as variable declaration, operators, input/output statements, and control structures. The cheat sheet serves as a concise guide for understanding fundamental C programming concepts.
global declarations using namespace std; constant PI = 3.14; const float PI = 3.14; Variable S : int; main() int main() begin { { print( "Hello world" ); local variable deceleration int S ; statement sequences cout<<" Hello world "; } return 0; End. }
Syntax of Algorithmic Language vs. C Language
Algorithmic Language C Language Types int, real, char, Boolean int, float, char, Bool Variables Variable idfs : Type ; Type idfs ; Declaration Example: Variable x, y, z: int; Example: int x, y, z;
End> Comments /**/ /**/ algorithmic Language C Language if (condition) then action 1 ; if (condition) action 1; else action 2 ; endif ; else action 2; max x ; max=x ; if(y>max) then if(y>max) max y; max=y ; endif ; cout<<" maximum : " << max ; print("maximum : ", max) ;
if(x>y) then if(x>y) {
maxx ; max = x ; print(“maximum : “,max); cout<<" maximum: "<< max ; else } maxy ; else { print((“maximum : “, max) ; max = y ; cout<<" maximum: "<< max ; Endif ; }
case choice of switch (choice)
List_val1 : action 1 ; { List_val2 : action 2 ; case liste_val1 : action 1; break; …. case liste_val2 : action 2; break; List_valn : action n ; ….. otherwise : action x ; case liste_val1 : action 1; break; Endcase ; default : action x; } i2 ; i= 2; case i of switch (i) 1,2 : i2-i; { 3 : i0; case 1: otherwise : print(" Erreur") ; case 2: i=2-i; break; Endcase ; case 3: i=0; default: cout<<" Error" ; }