Cse Lab Report-01
Cse Lab Report-01
#include <stdio.h>
int main()
{
Output:
Question 02:
Input:
#include <stdio.h>
int main()
{
printf(" B\nB E C M\n C\n M\n");
return 0;
}
Page 2
Output:
B
BECM
C
M
Inpute:
#include <stdio.h>
int main()
{
printf("B\n E\n C\n M\n");
printf("K\n U\n E\n T\n");
return 0;
}
Output:
B
E
C
M
K
U
E
T
Input:
#include <stdio.h>
int main()
{
printf(" *\n* *\n *\n");
return 0;
}
Page 3
Output:
*
* *
*
Input:
#include <stdio.h>
int main()
{
printf("*\n* *\n* * *\n* * * *\n");
return 0;
Output:
*
**
***
****
Input:
#include <stdio.h>
int main()
{
printf(" *\n * *\n * * *\n* * * *\n");
return 0;
}
Output:
*
**
***
****
Page 4
Question 03: Develop a program to add, multiply, and divide between two
numbers using scanf.
Input:
#include <stdio.h>
int main(){
int num1, num2, add, sub, mul;
float div;
printf("Enter the first number:");
scanf("%d",&num1);
printf("Enter the second number:");
scanf("%d",&num2);
add = num1+num2;
sub = num1-num2;
mul = num1*num2;
div = num1/num2;
printf("The result of the add is:%d\n",add);
printf("The result of the sub is:%d\n",sub);
printf("The result of the mul is:%d\n",mul);
printf("The result of the div is:%.2f\n",div);
return 0;
}
Output:
Enter the first number:10
Enter the second number:5
The result of the add is:15
The result of the sub is:5
The result of the mul is:50
Page 5
Question 04: Develop a program to find the area and circumference of the circle.
Input:
#include <stdio.h>
int main()
{
float area, circumference, pi = 3.14, radius;
printf("Enter the radius of the circle\n");
scanf("%f",&radius);
area = pi * radius * radius;
circumference = 2 * pi * radius;
printf("area of the circle%.2f\n",area);
printf("circumference of the circle%.2f\n",circumference);
return 0;
}
Output:
Enter the radius of the circle
5
area of the circle78.50
circumference of the circle31.40
Question 05: Develop a program to find the area and perimeter of the square.
Input:
#include <stdio.h>
int main()
Page 6
{
float area, perimeter, a ;
printf("Enter the a of the square\n");
scanf("%f",&a);
area = a * a;
perimeter = 4 * a ;
printf("area of the square%.2f\n",area);
printf("perimeter of the square%.2f\n",perimeter);
return 0;
}
Output:
Enter the a of the square
5
area of the square25.00
perimeter of the square20.00
Question 06: Develop a program to find the area and circumference of the
rectangle.
Input:
#include <stdio.h>
int main()
{
float area, perimeter, a,b ;
printf("Enter the a of the rectangle\n");
scanf("%f",&a);
printf("Enter the b of the rectangle\n");
Page 7
scanf("%f",&b);
area = a * b;
perimeter = 2 * ( a + b ) ;
printf("area of the rectangle%.2f\n",area);
printf("perimeter of the srectangle%.2f\n",perimeter);
return 0;
}
Output:
Enter the a of the rectangle
2
Enter the b of the rectangle
3
area of the rectangle6.00
perimeter of the srectangle10.00
Question 07: Develop a program to find the area and circumference of the
triangle.
Input:
#include <stdio.h>
int main()
{
float area, perimeter, base, height, side;
printf("Enter the base of the triangle\n");
scanf("%f",&base);
printf("Enter the height of the triangle\n");
scanf("%f",&height);
printf("Enter the side of the triangle\n");
Page 8
scanf("%f",&side);
area = 0.5 * base* height;
perimeter = side + side + side;
printf("area of the triangle%.2f\n",area);
printf("perimeter of the triangle%.2f\n",perimeter);
return 0;
}
Output:
Enter the base of the triangle
2
Enter the height of the triangle
3
Enter the side of the triangle
5
area of the triangle3.00
perimeter of the triangle15.00
Question 08: Develop a program to find the surface area and volume of a balon.
Input:
#include <stdio.h>
#include <stdlib.h>
int main()
{
float r,h,vol, area;
printf("\nenter the radius and height of the balon\n");
scanf("%f%f",&r,&h);
Page 9
vol=3.1416*h*r*r;
printf("volume of the cylinder is %.4f \n",vol);
area=(2*3.1416*r*h+2*3.1416*r*r);
printf("surface area of the cylinder is %.4f \n",area);
return 0;
}
Output:
enter the radius and height of the balon
5
7
volume of the cylinder is 549.7800
surface area of the cylinder is 376.9920
Question 09: Develop a program to find the surface area and volume of a cube.
Input:
#include <stdio.h>
int main(){
float face, area, vol;
printf("enter the side of the cube \n");
scanf("%f",&face);
area=6*face*face;
printf("surface area of the cube is %.4f\n",area);
vol=face*face*face;
printf("volume of the cube is %.4f",vol);
return 0;
}
Page 10
Output:
Enter the side of the cube
6
surface area of the cube is 216.0000
volume of the cube is 216.0000
Output:
Enter the principle: 1000000
Enter the rate :15
Enter the time: 10
Page 11
Input:
#include<stdio.h>
#include<conio.h>
int main(){
float celsius, fahr, kelvin;
printf("Enter temperature in celsius: ");
scanf("%f", &celsius);
fahr = 1.8 * celsius + 32.0;
kelvin = 273.15 + celsius;
printf("%0.2f Celsius = %0.2f Fahrenheit\n", celsius, fahr);
printf("%0.2f Celsius = %0.2f Kelvin",celsius, kelvin);
getch();
}
Output:
Enter temperature in Celsius: 35
35.00 Celsius = 95.00 Fahrenheit
35.00 Celsius = 308.15 Kelvin
Question 12: Develop a program to sum, average, standard deviation, and variance
of five randomly inputted numbers.
Input:
#include <stdio.h>
Page 12
#include <math.h>
int main()
{
double a, b, c, d, e, p, q, r, s, t, u;
printf("Please enter any 5 numbers:\n");
scanf("%lf\n %lf\n %lf\n %lf\n %lf", &a, &b, &c, &d, &e);
p = a + b + c + d + e;
q = p/5;
r = pow((a-q),2) + pow((b-q),2) + pow((c-q),2) + pow((d-q),2) + pow((e-q),2);
s = r/5;
t = sqrt(s);
u = pow(t,2);
printf("\nThe summation of the 5 numbers is: %0.2lf\n", p);
printf("\nThe average of the 5 numbers is: %0.2lf\n", q);
printf("\nThe standard deviation of the 5 numbers is: %0.4lf\n", t);
printf("\nThe variance of the 5 numbers is: %0.4lf\n", u);
return 0;
}
Output:
Please enter any 5 numbers:
5 3 7 45 8
The summation of the 5 numbers is: 68.00
The average of the 5 numbers is: 13.60
The standard deviation of the 5 numbers is: 15.7937
The variance of the 5 numbers is: 249.4400
Input:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
float l , w , h, volume,weight,Steel,cc,cement,sand,khoa,Brick ;
printf("\nenter the length=");
scanf("%f",&l);
printf("enter the width=");
scanf("%f",&w);
printf("enter the height=");
scanf("%f",&h);
volume = l * w * h;
weight= volume*150;
Steel=(weight*1)/100;
cc=weight-Steel;
cement=cc/7;
sand=(cc*2)/7;
khoa=(cc*4)/7;
Brick=(khoa*850)/100;
printf("volume=%f,\nweight=%f,\nSteel=%f,\ncc=%f,\ncement=%f,\nsand=%f,\nkhoa=%f,\nBri
ck=%f",volume,weight,Steel,cc,cement,sand,khoa,Brick);
return 0;
}
Output:
enter the length=100
enter the width=50
Page 14