Presentation is loading. Please wait.

Presentation is loading. Please wait.

Summary. Data Types int A; I am declaring a variable A, which is an integer.

Similar presentations


Presentation on theme: "Summary. Data Types int A; I am declaring a variable A, which is an integer."— Presentation transcript:

1 Summary

2 Data Types int A; I am declaring a variable A, which is an integer.

3 Arrays int A[50]; I am declaring an array A. This array has 50 elements, and each element is an integer. A[0] is the first element of the array A[49] is the last element of the array

4 if, else if ( statement) { your code here } else if ( statement) { your code here } else if (statement) { your code here } … else { your code here }

5 while while(statement) { your code here }

6 for for(initial condition ; statement ; final operation) { your code here }

7 function int foo(int A, int B) { int C; your code here return C; }

8 How to call your function void main() { int X; int Y; int Z; Z = foo (X, Y); printf(  foo(%d, %d) = %d\n , X, Y, Z); }

9 Struct typedef struct tag_name { type element1; type element2; } tag_name;

10 Struct Example #include typedef struct Student { int midterm;//%40 int hw;//%20 int final;//%40 int average; } Student; void main() { Student Veli; Veli.hw = 80; Veli.midterm = 90; Veli.final = 100; Veli.average = (Veli.hw*20 + Veli.midterm*40 + Veli.final*40)/100; printf("Veli has an average grade of %d \n", Veli.average); }

11 Base Arithmetic Binary numbers (base 2): Use only digits 0 and 1 Decimal numbers (base 10): Use digits 0,1,2,3,4,5,6,7,8,9 Hexadecimal numbers (bas 16): Use digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F – A = 10, B = 11, C = 12, D = 13, E = 14, F = 15

12 One’s and Two’s complement 1’s complemenf of an N-bit number: Invert all the bits in binary representation. 2’s complement of an N-bit number: subtract the number from 2 N.


Download ppt "Summary. Data Types int A; I am declaring a variable A, which is an integer."

Similar presentations


Ads by Google