• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Intro to c chapter cover 1 4
 

Intro to c chapter cover 1 4

on

  • 295 views

 

Statistics

Views

Total Views
295
Views on SlideShare
295
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Intro to c chapter cover 1 4 Intro to c chapter cover 1 4 Presentation Transcript

    • Created by: Arave
    • Flowchart
    • 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
    • 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; }
    • C Structure Preprocessor Directives Global Declarationvoid main(){ Local Declaration Statements}
    • Preprocessor Directives First statement executed by compiler Begin with a pound sign or hash ( # ) Example : #include and #define
    • Header Files/Libraries Header files have the extension .h two ways to include a header file: 1. #include "stdio.h" 2. #include <stdio.h>
    • Example#include <stdio.h> Header#include <stlib.h> filesvoid main(){printf("Hello world!!!");}
    • Input (printf) How to transfer/store the data to computer Interactive – keyboard, touch screen, mouse – response from user User understand type of input data
    • Example void main() { int num1; printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
    • Escape sequence functions n New line t Horizontal tab v Vertical tab b backspace a Bell or a beep backslash ’ Single quote ” double quote
    • Input (scanf) Address in which user input store temporary Symbol ‘&’ referred to address to the variable
    • Example void main() { int num1; //variable printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
    • Variable type scanf Format Specifier int %d, %i float %f char %c long int %ld string %s double %lf
    • Type of arithmetic operatorType Meaning * Multiplication / Division and integer division Modulus % + Addition - Substraction
    • 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;
    • Order of precedence• Arithmetic Operation Priority High Priority() left to right++, -- left to right* , /, % left to right+,- left to right
    • 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
    • Type of Logical OperatorOperator Meaning Example && AND ((x<y)&&(x!=0)) || OR ((x<y)||(x!=0)) ! NOT !(x>=y)
    • Thank You!