SlideShare una empresa de Scribd logo
1 de 20
Created by: Arave
Flowchart
Example flowchart
                                   Begin
Problem: Add 2 numbers
Pseudo code
1. Begin                       Read number 1
2. Read number 1
3. Read number 2
                               Read number 2
4. Add number 1 & number 2
5. 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
              Declaration
void 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>          files
void 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 operator
Type       Meaning

       *   Multiplication

       /   Division and integer division

           Modulus
       %
       +   Addition

       -   Substraction
Unary Operator


Operator   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 Operator
Operator   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 Operator
Operator   Meaning Example

  && AND            ((x<y)&&(x!=0))


  || OR             ((x<y)||(x!=0))


   ! NOT               !(x>=y)
Thank You!

Más contenido relacionado

La actualidad más candente

C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)SURBHI SAROHA
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)SURBHI SAROHA
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functionsWay2itech
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in CMuthuganesh S
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programmingSabik T S
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)SURBHI SAROHA
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C ProgrammingKamal Acharya
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in cSaranya saran
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branchingSaranya saran
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7Rumman Ansari
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6Rumman Ansari
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5Rumman Ansari
 

La actualidad más candente (20)

C programming(Part 1)
C programming(Part 1)C programming(Part 1)
C programming(Part 1)
 
Programming in C (part 2)
Programming in C (part 2)Programming in C (part 2)
Programming in C (part 2)
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C Programming
 
Working with IDE
Working with IDEWorking with IDE
Working with IDE
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
What is c
What is cWhat is c
What is c
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
Unit ii ppt
Unit ii pptUnit ii ppt
Unit ii ppt
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
C Programming Language Part 6
C Programming Language Part 6C Programming Language Part 6
C Programming Language Part 6
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C ProgrammingLecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
 
C programming
C programmingC programming
C programming
 
C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 

Destacado

Flowchart Example
Flowchart ExampleFlowchart Example
Flowchart Examplebigdeecross
 
Symbol for drawing flowchart
Symbol for drawing flowchartSymbol for drawing flowchart
Symbol for drawing flowchartKamal Tamang
 
Table Of Flowchart Symbols
Table Of Flowchart SymbolsTable Of Flowchart Symbols
Table Of Flowchart SymbolsNeo Nguyens
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
 
Flowchart symbols meaning explained
Flowchart symbols meaning explainedFlowchart symbols meaning explained
Flowchart symbols meaning explainedEliza Wright
 
Presentation on diagram and flowchart
Presentation on diagram and flowchartPresentation on diagram and flowchart
Presentation on diagram and flowchartSwarnima Tiwari
 
Flow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesFlow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesSlideTeam.net
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C LanguageAryan Ajmer
 

Destacado (13)

Flowchart Example
Flowchart ExampleFlowchart Example
Flowchart Example
 
Symbol for drawing flowchart
Symbol for drawing flowchartSymbol for drawing flowchart
Symbol for drawing flowchart
 
Chapter 6 Flowchart
Chapter 6   FlowchartChapter 6   Flowchart
Chapter 6 Flowchart
 
Table Of Flowchart Symbols
Table Of Flowchart SymbolsTable Of Flowchart Symbols
Table Of Flowchart Symbols
 
Flow charts
Flow chartsFlow charts
Flow charts
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 
Flowchart symbols meaning explained
Flowchart symbols meaning explainedFlowchart symbols meaning explained
Flowchart symbols meaning explained
 
Presentation on diagram and flowchart
Presentation on diagram and flowchartPresentation on diagram and flowchart
Presentation on diagram and flowchart
 
Flowchart
FlowchartFlowchart
Flowchart
 
Flow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templatesFlow chart powerpoint presentation slides ppt templates
Flow chart powerpoint presentation slides ppt templates
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 

Similar a Intro to c chapter cover 1 4

presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxKrishanPalSingh39
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c programNishmaNJ
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4MKalpanaDevi
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariTHE NORTHCAP UNIVERSITY
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxKrishanPalSingh39
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxLikhil181
 
Lecture 3 and 4.pptx
Lecture 3 and 4.pptxLecture 3 and 4.pptx
Lecture 3 and 4.pptxMAHAMASADIK
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1Little Tukta Lita
 
Control structure of c
Control structure of cControl structure of c
Control structure of cKomal Kotak
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about CYi-Hsiu Hsu
 

Similar a Intro to c chapter cover 1 4 (20)

2. operator
2. operator2. operator
2. operator
 
C tutorial
C tutorialC tutorial
C tutorial
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
 
Functions
FunctionsFunctions
Functions
 
1 introduction to c program
1 introduction to c program1 introduction to c program
1 introduction to c program
 
7 functions
7  functions7  functions
7 functions
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Fundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan KumariFundamentals of computer programming by Dr. A. Charan Kumari
Fundamentals of computer programming by Dr. A. Charan Kumari
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
C_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptxC_Programming_Language_tutorial__Autosaved_.pptx
C_Programming_Language_tutorial__Autosaved_.pptx
 
Lecture 3 and 4.pptx
Lecture 3 and 4.pptxLecture 3 and 4.pptx
Lecture 3 and 4.pptx
 
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
โปรแกรมย่อยและฟังชั่นมาตรฐาน ม.6 1
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Understand more about C
Understand more about CUnderstand more about C
Understand more about C
 
Functions struct&union
Functions struct&unionFunctions struct&union
Functions struct&union
 

Último

How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptxDhatriParmar
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDhatriParmar
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvRicaMaeCastro1
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseCeline George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4JOYLYNSAMANIEGO
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Último (20)

How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
Unraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptxUnraveling Hypertext_ Analyzing  Postmodern Elements in  Literature.pptx
Unraveling Hypertext_ Analyzing Postmodern Elements in Literature.pptx
 
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptxDecoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
Decoding the Tweet _ Practical Criticism in the Age of Hashtag.pptx
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnvESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
ESP 4-EDITED.pdfmmcncncncmcmmnmnmncnmncmnnjvnnv
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
How to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 DatabaseHow to Make a Duplicate of Your Odoo 17 Database
How to Make a Duplicate of Your Odoo 17 Database
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4Daily Lesson Plan in Mathematics Quarter 4
Daily Lesson Plan in Mathematics Quarter 4
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

Intro to c chapter cover 1 4

  • 3. Example flowchart Begin Problem: Add 2 numbers Pseudo code 1. Begin Read number 1 2. Read number 1 3. Read number 2 Read number 2 4. Add number 1 & number 2 5. End Answer = no1 + no2 End
  • 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. C Structure Preprocessor Directives Global Declaration void main() { Local Declaration Statements }
  • 6. Preprocessor Directives  First statement executed by compiler  Begin with a pound sign or hash ( # )  Example : #include and #define
  • 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. Example #include <stdio.h> Header #include <stlib.h> files void main() { printf("Hello world!!!"); }
  • 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. Example void main() { int num1; printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
  • 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. Input (scanf)  Address in which user input store temporary  Symbol ‘&’ referred to address to the variable
  • 13. Example void main() { int num1; //variable printf(“Key-in number: "); //Input scanf(“%d”,&num1); . . . . . . return 0; }
  • 14. Variable type scanf Format Specifier int %d, %i float %f char %c long int %ld string %s double %lf
  • 15. Type of arithmetic operator Type Meaning * Multiplication / Division and integer division Modulus % + Addition - Substraction
  • 16. Unary Operator Operator 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. Order of precedence • Arithmetic Operation Priority High Priority () left to right ++, -- left to right * , /, % left to right +,- left to right
  • 18. Type of Relational Operator Operator 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. Type of Logical Operator Operator Meaning Example && AND ((x<y)&&(x!=0)) || OR ((x<y)||(x!=0)) ! NOT !(x>=y)