Professional Documents
Culture Documents
int String
float Array
double union
char structure
enum
int
The data type that consists of numeric values
without decimal point is called int data type.
Float
Date type Memory Value Minimum Maximum Accuracy up to Min in Max in Min in Max in
Allocation (Bytes) ± decimal points exponent exponent float.h float.h
G. Syntax ++X
a=10; a=10; Result
Equals
b=++a; a=a+1; b=11
b=a; a=11
Output
Anything received from computer is called output.
Output Function
The function that is used to output some data
from program is called output function.
int Num=3;
if(Num%2);
/*Well! It executes well but the output is nothing */
}
getch();
}
Logical Expression
The expression in which logical operators are used is
called logical expression. It always produces result
true of false.
T F
Exp2
Exp1
T T F
F F F
21 write a program to input three numbers print
out greater among them use logical operators.
Object oriented programming pre-requisite 2/24/2015 95
22 write a program to input percentage of the
student print out its grade according to
percentage criteria.
23 write a program to input any character print
out whether it is digit or not. Use conditional
and logical operators.
T F
Exp2
Exp1
T T T
F T F
End of Chapter#2
Object oriented programming pre-requisite 2/24/2015 99
CHAPTER # 03
while loop
do while loop
for loop
while loop
The loop that executes the statement(s) until given
condition remains true is called while loop. It
checks the condition first then executes the
statement(s), that’s why it is called pre-test loop.
Execution
1
2
3
4
5
6
7
8
9
10
Object oriented programming pre-requisite 2/24/2015 106
2 write a program to print out all even numbers
up to 100.
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int i=0;
while(i<=100)
{
printf("%d\n",i);
i+=2;
}
getch();
}
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int Counter=2048;
while(Counter>0)
{
printf("%d\t",Counter);
Counter/=2; //Counter=Counter/2;
}
getch();
}
G. Syntax
for(initialization;test;increment/decrement)
{
Statement(s);
}
getch();
Object oriented programming pre-requisite 2/24/2015 132
Reference
G. Syntax
sizeof(dataitem);
Pass by address
When arguments are passed by addresses and received by
pointers any change in the pointer can modify the original
contents of arguments in caller function.