sysprog2 Part1

648 views
598 views

Published on

first part of the second session in phase I of system programming sessions in eglug

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
648
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
13
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

sysprog2 Part1

  1. 1. C for Linux Session 2  C Syntax BY: Eng.Riham AlDakkak System Administrator    
  2. 2. Getting Started What tools do I need to get started? ● gcc, text editor – Say hello to the world in C  ● Compilation and execution – A Closer look at the program  –    
  3. 3. A look at a C program structure General form of a C program is as  ● pre­processor directives – global declarations – main() – other functions –    
  4. 4. Variables Variable declaration ● C is a static typing language  – int x, y; ● int x=0, y=1;  //initialization ● Language Predefined data types – double, float ● (signed, unsigned ) int, short, long, long long ● char, unsigned char – ASCIIure ●    
  5. 5. Variable Declaration: Continue Language Predefined data types ● Memory  – User defined types: typedef, structure ●    
  6. 6. Scopes Global Variables ● {} operator ● Example on scopes ●    
  7. 7. Operators Arithmetic (*, / ,% ,+ ,­ ,pre/post++, pre/post­­)  ● Relational (<,>,<=,>=,==,!=, !) ● Logical (&&, ||) and Bitwise (>> ,<< ,& ,^ ,| ,~ ) ● Assignment (=,+=,­=,*=,/=,<<=,>>=, %=,| ● =,&=,^=) http://en.wikipedia.org/wiki/Operators_in_C_and ● _C++    
  8. 8. Casting  Explicit cast ● char x = 'a'; int y = (int) x; – int x = 5; char y = (char) x; – Arithmetic Conversions ● Widening – Type balancing – Sign balancing –    
  9. 9. Conditionals If statement ● switch statement ● ternary operator ? ● x=10; – y = x>9 ? 100:200; –    
  10. 10. Loops for example ● while example ● do while example ● break and continue example (good point to  ● show infinite loop)    

×