Your SlideShare is downloading. ×
2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2

109
views

Published on

Published in: Technology, Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
109
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. C
  • 2. Topic o Language program o Compile & Run program o Structure of C program o
  • 3. • • Language) (Low-Level (Machine language) (MiddleLevel Language) (Assembly Language) (High-Level Language) Pascal, Fortran, C, JAVA, …
  • 4. 1. (Machine Language) • 2 (0/1) o o Object Code
  • 5. (Assembly Language) • 2 o o ( )
  • 6. 6
  • 7. • Languages) – (High-Level C, JAVA, Interpreter (Compiler) • Compiler ( Pascal, C, ...) • Interpreter
  • 8. Compile • • Source code (file) C Machine code (Object file) C
  • 9. Compile & Run C • main) • C ( Edit
  • 10. C • Preprocessor Directive ( • Main Function ( 1 Void main() 2 { 3 statements; 5 • ) Programming #include<stdio.h> 2 void main() 3 { 4 5 End } 1 n /* main function */ / Begin ( ) variable declaration; 4 ) printf("C Programmingn"); } cursor C /* Preprocessor directive*/
  • 11. C • 4 C 1. Statements) 2. Statements) 3. Statements) 4. Statements) • (Input / Output (Expression (Conditioning (Looping int x, y float
  • 12. • printf ( stdio) C Memory stdio Preprocessor Directive o printf main • printf(“control string”, variable,…);  control string o printf(“C o variable ( Programming”); ) %d integer decimal %f Memory o %format %d, %f, %c, %s real o variable o n (new line), … floating point
  • 13.  Programming C
  • 14. Memory variable (X) • scanf ( stdio.h) • … Address 0 1 2 (&X) 3 4 … scanf(“%format,…”, &variable,…); o %format o &variable %d, %f, %c, %s (Address) scanf(“%d”, &X); variable integer %d integer decimal %f real floating point X &X
  • 15.  2 (X, Y) (Sum) Memory start X Y Input X,Y #include<stdio.h> SUM void main() { int X, Y, SUM; printf("Enter X:"); scanf("%d", &X); SUM = X+Y printf("Enter Y:"); scanf("%d", &Y); Print SUM SUM = X+Y; printf("Sum = %dn", SUM); end } printf (Output) o scanf C o C (Input) 50 100 150
  • 16. % format • %format scanf, printf (integer) (real) %format int %d float %f #include<stdio.h> void main() { int X, Y, sum; printf("Enter X:"); scanf("%d",&X); printf("Enter Y:"); scanf("%d",&Y); sum = X+Y printf("sum = %dn", sum); } Memory X Y SUM
  • 17. 3 W Area L  (Area) Width x Length ( #include<stdio.h> x Area = ) start Input W,L void main() Area = W*L { int W,L; float Area; printf("Enter width:"); scanf("%d", &W); printf("Enter length:"); scanf("%d", &L); Area = W*L; printf("Area = %fn", Area); } Print Area end Enter width: 5 _ Enter length: 10 _ Area = 50.0
  • 18. 4 1 2 3 4 5 6 7 8 9 10 11 12 1  ( #include<stdio.h> ) start Input Feet F void main() Inches = Feet*12 { int F,Inches; Print Inches printf("Enter feet:"); scanf("%d", &W); end inches = F*12; printf("=%d inchesn", Inches); } Memory 2 Enter feet: _ = 24 inches Inches
  • 19. getchar, gets • scanf “%format o •  getchar() ENTER Character  getch() ENTER Library “stdio” Library “conio”
  • 20. (Day),  (Year) November, 2013 Month day, year ( 1, 2013 ) #include<stdio.h> void main() 1, (Month), Memory November Day Year Month { int Day, Year; 1 2013 N o v e m b e r char Month[20];//string printf("Enter Day:");scanf("%d",&Day); printf("Enter Month:");scanf("%s",&Month); printf("Enter Year:");scanf("%d",&Year); 1 Enter Day: _ printf("Date is %s %d,%dn",Month, Day, Year); Enter Month: November _ fflush(stdin);getchar(); 2013 Enter Year: _ } Date is November 1, 2013 Keyboard

×