1 / 12

Summary

Summary. Data Types. int A; I am declaring a variable A, which is an integer. 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.

Download Presentation

Summary

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Thisarray has 50 elements, andeach element is an integer. A[0] is thefirst element of thearray A[49] is thelast element of thearray

  4. if, else if, else if ( statement) { yourcode here } else if ( statement) { yourcode here } else if (statement) { yourcode here } … else { yourcode here }

  5. while while(statement) { yourcode here }

  6. for for(initialcondition ; statement ; final operation) { yourcode here }

  7. function intfoo(int A, int B) { int C; yourcode here return C; }

  8. How tocallyourfunction void main() { int X; int Y; int Z; Z = foo (X, Y); printf(foo(%d, %d) = %d\n, X, Y, Z); }

  9. Struct typedefstructtag_name { type element1; type element2; } tag_name;

  10. StructExample #include<stdio.h> typedefstructStudent { intmidterm;//%40 inthw;//%20 intfinal;//%40 intaverage; } Student; void main() { StudentVeli; 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 • Binarynumbers (base 2): Useonlydigits 0 and 1 • Decimalnumbers (base 10): Usedigits 0,1,2,3,4,5,6,7,8,9 • Hexadecimalnumbers (bas 16): Usedigits 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’sandTwo’scomplement • 1’s complemenf of an N-bit number: Invertallthebits in binaryrepresentation. • 2’s complement of an N-bit number: subtractthenumberfrom 2N.

More Related