Saturday, March 6, 2021

C program to calculate and print the simple interest.

 

1.     Write a C program to calculate and print the simple interest.

 

#include<stdio.h>

#include<conio.h>

int main()

{

float p, t, r, i;

printf("Enter principal: ");

scanf("%f", &p);

printf("Enter time: ");

scanf("%f", &t);

printf("Enter rate: ");

scanf("%f", &r);

i = (p*t*r)/100;

printf("Simple Interest = %.2f", i);

return 0;

}

C program in QBASIC to find the total surface area of a box.

 

1.     Write a C program in QBASIC to find the total surface area of a box.

 

#include<stdio.h>

#include<conio.h>

int main()

{

int l,b,h,a;

printf("Enter length: ");

scanf("%d", &l);

printf("Enter breadth: ");

scanf("%d", &b);

printf("Enter height: ");

scanf("%d", &h);

a=2*((l*b)+(b*h)+(h*l));

printf("Total surface area of box= %d", a);

return 0;

}

C program to calculate the area of four walls.

 

1.     Write a C program to calculate the area of four walls.

 

#include<stdio.h>

#include<conio.h>

int main()

{

int l,b,h,a;

printf("Enter length: ");

scanf("%d", &l);

printf("Enter breadth: ");

scanf("%d", &b);

printf("Enter height: ");

scanf("%d", &h);

a=2*h*(l+b);

printf("Area of four walls= %d", a);

return 0;

}

C program to get radius of a circle and then print its circumference.

 

1.     Write a C program to get radius of a circle and then print its circumference.

 

#include<stdio.h>

#include<conio.h>

int main()

{

float r, c;

printf("Enter radius: ");

scanf("%f", &r);

c=2*(22/7)*r;

printf("Circumference of circle= %.2f", c);

return 0;

}

C program to calculate and print the volume of a box.

 

1.     Write a C program to calculate and print the volume of a box.

 

#include<stdio.h>

#include<conio.h>

int main()

{

int l,b,h,v;

printf("Enter length: ");

scanf("%d", &l);

printf("Enter breadth: ");

scanf("%d", &b);

printf("Enter height: ");

scanf("%d", &h);

v=l*b*h;

printf("Volume of box= %d", v);

return 0;

}

C program using to get radius of circle and then print its area.

 

1.     Write a C program using to get radius of circle and then print its area.

 

#include<stdio.h>

#include<conio.h>

int main()

{

float r, a;

printf("Enter radius: ");

scanf("%f", &r);

a=(22/7)*r*r;

printf("Area of circle= %.2f", a);

return 0;

}

C program to calculate distance travelled by a body.

 

1.     Write a C program to calculate distance travelled by a body.

 

#include<stdio.h>

#include<conio.h>

int main()

{

float u, a, s;

int t;

printf("Enter initial velocity: ");

scanf("%f", &u);

printf("Enter acceleration: ");

scanf("%f", &a);

printf("Enter time: ");

scanf("%d", &t);

s=(u*t)+(a*t*t)/2;

printf("Distance travelled by body= %.2f", s);

 

return 0;

}

C program to calculate the volume of a cylinder.

 

1.     Write a C program to calculate the volume of a cylinder.

#include<stdio.h>

#include<conio.h>

int main()

{

float r, h, v;

printf("Enter radius and height: \n");

scanf("%f %f", &r, &h);

v=(22/7)*r*r*h;

printf("Volume of cylinder= %.2f",v);

return 0;

}

C program to calculate the average of three numbers.

 

1.     Write a C program to calculate the average of three numbers.

 

#include<stdio.h>

#include<conio.h>

int main()

{

    int a,b,c;

    float d;

    printf("Enter first number: ");

    scanf("%d", &a);

    printf("Enter second number: ");

    scanf("%d", &b);

    printf("Enter second number: ");

    scanf("%d", &c);

    d=(a+b+c)/3;

    printf("Average of two numbers= %.2f",d);

    return 0;

}

C program to find the average of any two numbers given by the user.

 

 

1.     Write a C program to find the average of any two numbers given by the user.

 

#include<stdio.h>

#include<conio.h>

int main()

{

    int a,b;

    float c;

    printf("Enter first number: ");

    scanf("%d", &a);

    printf("Enter second number: ");

    scanf("%d", &b);

    c=(a+b)/2;

    printf("Average of two numbers= %.2f",c);

    return 0;

}