Intro to c chapter cover 1 4

387 views
307 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
387
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Intro to c chapter cover 1 4

  1. 1. Created by: Arave
  2. 2. Flowchart
  3. 3. Example flowchart BeginProblem: Add 2 numbersPseudo code1. Begin Read number 12. Read number 13. Read number 2 Read number 24. Add number 1 & number 25. End Answer = no1 + no2 End
  4. 4. Example C Programming #include <stdio.h> //Preprocessor Directives int main () { //Local Declaration int a, b, sum; //Statements printf("Enter two numbersn: "); scanf("%d %d", &a, &b); //Operation sum = a + b; //Output printf("The total is:%d", sum); getch (); return 0; }
  5. 5. C Structure Preprocessor Directives Global Declarationvoid main(){ Local Declaration Statements}
  6. 6. Preprocessor Directives First statement executed by compiler Begin with a pound sign or hash ( # ) Example : #include and #define
  7. 7. Header Files/Libraries Header files have the extension .h two ways to include a header file: 1. #include "stdio.h" 2. #include <stdio.h>
  8. 8. Example#include <stdio.h> Header#include <stlib.h> filesvoid main(){printf("Hello world!!!");}
  9. 9. Input (printf) How to transfer/store the data to computer Interactive – keyboard, touch screen, mouse – response from user User understand type of input data
  10. 10. Example void main() { int num1; printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
  11. 11. Escape sequence functions n New line t Horizontal tab v Vertical tab b backspace a Bell or a beep backslash ’ Single quote ” double quote
  12. 12. Input (scanf) Address in which user input store temporary Symbol ‘&’ referred to address to the variable
  13. 13. Example void main() { int num1; //variable printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
  14. 14. Variable type scanf Format Specifier int %d, %i float %f char %c long int %ld string %s double %lf
  15. 15. Type of arithmetic operatorType Meaning * Multiplication / Division and integer division Modulus % + Addition - Substraction
  16. 16. Unary OperatorOperator Example Description Equivalent Statements ++ i++; Postfix i=i+1; i+=1; ++ ++i; Prefix i=i+1; i+=1; -- i--; Postfix i=i-1; i-=1; -- --i; Prefix i=i-1; i-=1;
  17. 17. Order of precedence• Arithmetic Operation Priority High Priority() left to right++, -- left to right* , /, % left to right+,- left to right
  18. 18. Type of Relational OperatorOperator Description Example == equal to x==y > greater than x>y < less than x<y >= greater or x>=y equal <= less or equal x<=y != Not equal to x!=y
  19. 19. Type of Logical OperatorOperator Meaning Example && AND ((x<y)&&(x!=0)) || OR ((x<y)||(x!=0)) ! NOT !(x>=y)
  20. 20. Thank You!

×