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>
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
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)