2. 1. PROGRAM TO DISPLAY “HELLO WORLD”
2. ARITHMETIC OPERATORS
3. CALCULATE SIMPLE INTEREST
4. CALCULATE AREA OF CIRCLE, TRIANGLE,
RECTANGLE
2
MANJUNATH
C
R
PRACTICE PROGRAMS
8. ARITHMETIC OPERATORS
ALGORITHM:
STEP 1: Start
STEP 2: Declare the variables a, b, sum, diff, mul, div
STEP 3: Input the values a, b
STEP 4: sum a + b
diff b – a
mul a * b
div b / a
STEP 5: Print the value of sum, diff, mul, div
STEP 6: Stop
8
MANJUNATH
C
R
10. ARITHMETIC OPERATORS
#include<stdio.h>
#include<conio.h>
void main()
{
intt a, b , sum, dif, mul, div;
printf("ENter value of A & B ");
scanf(“%d %d", &a, &b);
sum = a + b;
dif = a - b;
mul = a * b;
div = b / a;
printf("Sum = %d n", sum);
printf("Diff = %d n", dif);
printf("Mul = %d n", mul);
printf("Div = %d n", div);
getch();
}
10
MANJUNATH
C
R
12. CALCULATE SIMPLE INTEREST
ALGORITHM:
STEP 1: Start
STEP 2: Declare variables p, t, r, si
STEP 3: Input the values of p, t, r
STEP 4: si (p * t * r) / 100
STEP 5: Display value of si
Step 6: Stop
12
MANJUNATH
C
R
16. CALCULATE AREA OF CIRCLE, TRIANGLE, RECTANGLE
ALGORITHM:
Step 1: Start
Step 2: Declare variables r, area_cir, b, h, area_tri, l, w,
area_rec;
Step 3: Input the values r, b, h, l, w
Step 4: area_cir 3.14 * r * r
area_tri 0.5 * b * h
area_rec l * w
Step 5: Display the values of area_cir, area_tri, area_rec
Step 6: Stop
16
MANJUNATH
C
R
18. #include<stdio.h>
#include<conio.h>
void main()
{ float r, area_cir, b, h, area_tri, l, w, area_rec;
printf("Enter the value of r: ");
scanf("%f", &r);
area_cir = 3.14 * r * r;
printf("Area of Circle = %f n", area_cir);
printf("Enter the value of b and h:");
scanf("%f %f", &b, &h);
area_tri = 0.5 * b * h;
printf("Area of Triangle = %f n", area_tri);
printf("Enter the value of l and w:");
scanf("%f %f", &l, &w);
area_rec = l * w;
printf("Area of Rectangle = %f n", area_rec);
getch();
}
18
MANJUNATH
C
R
CALCULATE AREA OF CIRCLE, TRIANGLE, RECTANGLE