C Program Lab
C Program Lab
Main Function: 6
Data type: 4
int 4 byte 32 bit %d Integer type value
float 4 byte 32 bit %f decimal
double 8 byte 64 bit %lf
char 1 byte 8 bit %c character
Variable: data name that store data value
1.letter,digit,underscore(_)
2.begin with letter(length 31
character)
Declaration does 2 things:
1. tells compiler
variable name
2. data type that
variable hold
Global variable: declared before the main
function
1.Keywords (int,float,void,while,else,if,switch,return)
Local Variable: declared
2.Identifier inside the main
(amount)--name of a variable
function
3.constant (-15.5,100)
C token:
4.strings (abc)
5.operators (+-*/)
6.special symbols ( {}, [] )
Comment: /*…………………..*/
#include<math.h> : mathematical function(cos,sin,pow,sqrt)
#define : a symbolic constant (preprocessor directive)
#define x 52
#define PI 3.1416
#include<conio.h> : console input output (getchar,putchar,clrscr)
Reading a single character function: getchar()
%c : read single character
%s : read string
Loop : 3
for Initialization;test condition;increment Pre-test loop
while Entry control loop Pre-test loop
Do…while Exit control loop Post-test loop