3. VARIABLE
VARIABLE IS THE NAME OF A MEMORY
LOCATION WHICH STORES SOME DATA.
Variables Rules
Variable are case sensitive
1st character is alphabet or ‘_’
No comma/blank space
No other symbol other than’_’
4. VARIABLE DATA TYPES
Data Type Size In Bytes
Char or signed char 1
Unsigned char 1
Int or signed int 2
Unsigned int 2
Short int or Unsigned short int 2
Signed short int 2
Long int or signed long int 4
Unsigned long int 4
Float 4
Double 8
Long Double 10
5. CONSTANTS
Value that don’t change (fixed)
Types
Integer Constants 1,2,3,0,-1,-2
Real Constants 1,0,2,0,3.14,2.4
Character Constants ‘a’,’b’,’A’,’#’,’&’
6. KEYWORDS
Reserved words that have special meaning to the
compiler
32 Keyword in C
auto double int Struct
break else long Switch
case enum register Typedef
char extern return Union
continue for signed Void
do if static While
default goto sizeof Volatile
const float short unsigned
9. OUTPUT
Printf(“hello world”);
New Line
Printf(“hello world n”);
OUTPUT
CASES
1. Integers
Printf(“age is %d”,age);
2. Real Number
Printf(“value of pi is %f”,pi);
3. Characters
Printf(“star looks like this %c”, star);
Programm
#include<stdio.h>
Int main ()
{
Int age = 22;
Printf(“age is %d”, age);
Return 0;
}
10. INPUT
I/o Program
Scanf(“%d”,&age);
# include<stdio.h>
Int main()
{
Int a,b;
Printf(“enter a”);
scanf(“%d”,&a);
Printf(“enter b”);
Scanf(“%d”,&b);
//Int sum = a+b;
//Printf(“sum is : %d”, sum);
Printf(“sum is : %d”, a+b);
Return 0;
}
11. COMPILATION
A computer program that transaction C code into machine code
Practice Qs 1
1- Write a program to calculate area of a square (side is given)
#include<stdio.h>
// area of square
Int main()
Int side ;
Printf(“enter side”);
Scanf(“%d”, &side);
Printf(“area is : %d”, side * side);
Return 0;
2- Write a program to calculate are of a circle. (side is given)
#include<stdio.h>
// area of square
Int main()
Float radius ;
Printf(“enter radius”);
Scanf(“%f”, &radius);
Printf(“area is : %f”, 3.14 * redius * redius);
Return 0;