C Program To Calculate Average Of four Integer




 it is a single number that is used to represent a collection of numbers.                    

Average =Sum/Count 

#include<stdio.h>
int main()
{
int a,b,c,d;
float avg;
printf("Enter four numbers:\n");
scanf("%d%d%d%d",&a,&b,&c,&d);
avg=(a+b+c+d)/4.0;                 //4.0 is for type casting
printf("Average=%f\n",avg);
}

OUTPUT:
Enter four numbers:
25
65
45
88
Average=55.750000



Program to calculate area and perimeter of rectangle, sqare and circle using C language

 
         
       
Shape
Area
Perimeter
Rectangle
Length x width
2*(length+width)
Square
Side x side
Side x 4
Circle
πr2
2πr


#include <stdio.h>
int main()
{
int length,width,side;
float radius,pi=3.14;
int a_rect,p_rect,a_sq,p_sq;
float a_cir,p_cir;

printf("Enter length and width for rectangle\n");
scanf("%d%d",&length,&width);
printf("Enter sides of the square\n");
scanf("%d",&side);
printf("Enter radius of the circle\n");
scanf("%f",&radius);
a_rect=length*width;
p_rect=2*(length+width);
a_sq=side*side;
p_sq=4*side;
a_cir=pi*radius*radius;
p_cir=2*pi*radius;
printf("For rectangle:Area=%d, Perimeter.=%d\n",a_rect,p_rect);
printf("For square:Area=%d, Perimeter=%d\n",a_sq,p_sq);
printf("For circle:Area=%f, Perimeter=%f\n",a_cir,p_cir);
}

OUTPUT:
Enter length and width for rectangle
18 15
Enter sides of the square
12
Enter a radius of the circle
6.5
For rectangle:Area=270, Perimeter.=66
For square:Area=144, Perimeter=48

For circle:Area=132.664993, Perimeter=40.820000



C program to calculate simple interest


       Simple interest is a method of calculating interest charged on fixed deposit
    Formula  i=(Ptr/100)
    Where i:Interese
               p:Principal
               t:time period
               r:rate of interest/year

    #include <stdio.h>
    int main()
    {
    int principal,time;
    float r,i;
    printf("input principal amount\n");
    scanf("%d",&principal);
    printf("input time (in year)\n");
    scanf("%d",&time);
    printf("input the rate of interest\n");
    scanf("%f",&r);
    i=(principal*time*r)/100;
    printf("Total interest %f\n",i);
    }

  OUTPUT:
     input principal amount
    10000
     input time (in year)
     4
     input the rate of interest
     7.5
     total interest 3000.000000