You are on page 1of 24

/*Develop and execute a program to obtain volumes and areas of regular bodies and figures*/

#include<stdio.h>

#include<conio.h>

main()

float A,s,A_c,rc,hc,A_r,lr,br,A_t,Rt,rt,A_s,Ac,Vc,r,h,V_c,V,V_t,V_p,lp,wp,hp,V_s,rs;

printf(" OUTPUT ");

printf("\n Enter the value of side");

scanf("%f",&s);

A=6*s*s;

V=s*s*s;

printf("\n The area of cube =%f",A);

printf("\n The volume of cube =%f",V);

printf("\n enter the values of radius and height of cylinder");

scanf("%f%f",&rc,&hc);

A_c=2*3.14*rc*hc;

V_c=3.14*rc*rc*hc;

printf("\n The area of cyllinder =%f",A_c);

printf("\n The volume of cylinder =%f",V_c);

printf("\n Enter the value of length and breadth of rectangle");

scanf("%f%f",&lr,&br);

A_r=lr*br;

printf("\n Area of rectangle =%f",A_r);


printf("\n Enter the values of outer radius and inner radius of torus");

scanf("%f%f",&Rt,&rt);

A_t=3.14*3.14*(Rt*Rt-rt*rt);

V_t=0.25*3.14*3.14*(Rt+rt)*(Rt-rt)*(Rt-rt);

printf("\n The area of torus is %f",A_t);

printf("\n The volume of torus is %f",V_t);

printf("\n Enter the values of radius and height of cone");

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

Ac=3.14*r*r;

Vc=0.33*3.14*r*r*h;

printf("\n The area of cone =%f",Ac);

printf("\n The volume of cone =%f",Vc);

printf("\n Enter the value of length,width and height of pyramid");

scanf("%f%f%f",&lp,&wp,&hp);

V_p=0.33*lp*wp*hp;

printf("\n The volume of pyramid is%f",V_p);

printf("\n Enter the value of radius of sphere");

scanf("%f",&rs);

A_s=4*3.14*rs*rs;

V_s=1.33*3.14*rs*rs*rs;

printf("\n The area of sphere =%f",A_s);


printf("\n The volume of sphere =%f",V_s);

getch();

OUTPUT

Enter the value of side9

The area of cube =486.000000

The volume of cube =729.000000

enter the values of radius and height of cylinder6 7

The area of cyllinder =263.760010

The volume of cylinder =791.280029

Enter the value of length and breadth of rectangle4 5

Area of rectangle =20.000000

Enter the values of outer radius and inner radius of torus6 5

The area of torus is 108.455597

The volume of torus is 27.113899

Enter the values of radius and height of cone7 5

The area of cone =153.860001

The volume of cone =253.869003

Enter the value of length,width and height of pyramid2 3 4


The volume of pyramid is7.920000

Enter the value of radius of sphere5

The area of sphere =314.000000

The volume of sphere =522.025024

--------------------------------
/*Develop and execute a program to convert temperature from one system to other*/

#include<stdio.h>

#include<conio.h>

main()

float D,F,K;

printf(" OUTPUT ");

printf("\n Enter the value of temperarure in degree centigrate :");

scanf("%f",&D);

F=(D*1.8)+32;

printf("\n The temperature in Farenheit =%f",F);

printf("\n Enter the value of temperature in Farenheit :");

scanf("%f",&F);

D=(F-32)/1.8;

printf("\n The temperature in degree centigrate =%f",D);

printf("\n Enter the value of temperature in Kelvin :");

scanf("%f",&K);

F=1.8*(K-273)+32;

printf("\nThe temperature in Farenheit =%f",F);

printf("\n Enter the temperature in degree centigrate :");

scanf("%f",&D);

K=D+273;
printf("\n The temperature in Kelvin=%f",K);

getch();

OUTPUT

Enter the value of temperarure in degree centigrate :55

The temperature in Farenheit =131.000000

Enter the value of temperature in Farenheit :65

The temperature in degree centigrate =18.333334

Enter the value of temperature in Kelvin :47

The temperature in Farenheit =-374.799988

Enter the temperature in degree centigrate :32

The temperature in Kelvin=305.000000}


/*c program to find theAddition of two matrices*/
#include<stdio.h>
#include<conio.h>
main()
{
int r,c,m,n,A[10][10],B[10][10],C[10][10];
printf(" OUTPUT ");
printf("\n\n Enter the number of rows and columns");
scanf("%d%d",&r,&c);
printf("\n\n Enter the elements of first matrix :");
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
scanf("%d",&A[m][n]);
}
}
printf("\n Enter the elements of second matrix :");
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
scanf("%d",&B[m][n]);
}
}
printf("\n The first matrix is :\n\n");
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
printf("\t%d",A[m][n]);
}
printf("\n");
}
printf("\n The second matrix is :\n\n");
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
printf("\t%d",B[m][n]);
}
printf("\n");
}
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
C[m][n]=A[m][n]+B[m][n];
}

}
printf("\nThe addition of two matrices :\n\n");
for(m=0;m<r;m++)
{
for(n=0;n<c;n++)
{
printf("\t%d",C[m][n]);
}
printf("\n");
}
getch();

}
OUTPUT

Enter the number of rows and columns4 4

Enter the elements of first matrix :1 2 3 4 5 6 1 2 3 4 5 6 2 1 4 7

Enter the elements of second matrix :1 4 7 8 5 2 3 6 9 8 5 2 1 4 7 8

The first matrix is :

1 2 3 4
5 6 1 2
3 4 5 6
2 1 4 7
The second matrix is :

1 4 7 8
5 2 3 6
9 8 5 2
1 4 7 8

The addition of two matrices :

2 6 10 12
10 8 4 8
12 12 10 8
3 5 11 15
/* Develope and exacute program for Subtraction of two matrices*/

#include<stdio.h>

#include<conio.h>

main()

int r,c,m,n,A[10][10],B[10][10],C[10][10];

printf(" OUTPUT ");

printf("\n\n Enter the number of rows and columns");

scanf("%d%d",&r,&c);

printf("\n\n Enter the elements of first matrix :");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

scanf("%d",&A[m][n]);

printf("\n\n Enter the elements of second matrix :");


for(m=0;m<r;m++)

for(n=0;n<c;n++)

scanf("%d",&B[m][n]);

printf("\n\ The first matrix is :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

printf("\t%d",A[m][n]);

printf("\n");

printf("\n The second matrix is :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

printf("\t%d",B[m][n]);

printf("\n");

}
for(m=0;m<r;m++)

for(n=0;n<c;n++)

C[m][n]=A[m][n]-B[m][n];

printf("\n The subtrsction of two matrices :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

printf("\t%d",C[m][n]);

printf("\n");

getch();

}
OUTPUT

Enter the number of rows and columns 4 4

Enter the elements of first matrix : 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7

Enter the elements of second matrix :9 8 7 4 5 6 3 2 1 2 3 4 5 6 7 8

The first matrix is :

1 2 3 4

5 6 7 8

9 1 2 3

4 5 6 7
The second matrix is :

9 8 7 4

5 6 3 2

1 2 3 4

5 6 7 8

The subtrsction of two matrices :

-8 -6 -4 0

0 0 4 6

8 -1 -1 -1

-1 -1 -1 -1

/*Develope and exacute a program to obtain the product of two matrices*/

#include<stdio.h>

#include<conio.h>

main()

int m,n,k,r,c,A[3][3],B[3][3],C[3][3];

printf(" OUTPUT ");

printf("\nEnter the number of rows and columns");


scanf("%d%d",&r,&c);

printf("\n\n The elements of first matrix :");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

scanf("%d",&A[m][n]);

printf("\n\n The elements of second matrix :");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

scanf("%d",&B[m][n]);

printf("\n The first matrix :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

printf("\t%d",A[m][n]);

printf("\n");
}

printf("\n The second matrix :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

printf("\t%d",B[m][n]);

printf("\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)

C[m][n]=0;

for(k=0;k<c;k++)

C[m][n]=C[m][n]+A[m][k]*B[k][n];

printf("\n The multiplication of two matrices :\n\n");

for(m=0;m<r;m++)

for(n=0;n<c;n++)
{

printf("\t%d",C[m][n]);

printf("\n");

getch();

OUTPUT

Enter the number of rows and columns 3 3

The elements of first matrix : 1 2 3 5 4 6 9 8 7

The elements of second matrix : 5 6 2 1 4 7 8 9 6

The first matrix :

1 2 3

5 4 6

9 8 7

The second matrix :


5 6 2

1 4 7

8 9 6

The multiplication of two matrices :

31 41 34

77 100 74

109 149 116

/*Develope and execute a program to obtain inverse of atrix*/

#include<stdio.h>

#include<conio.h>

main()

int m,n,A[3][3],cofA[3][3],adjA[3][3];

float detA,invA[3][3];

printf(" OUTPUT ");

printf("\n Enter the elements of matrix : ");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

scanf("%d",&A[m][n]);

}
}

printf("\n The entered matrix is:\n");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

printf("\t%d",A[m][n]);

printf("\n");

detA=(A[0][0]*(A[1][1]*A[2][2]-A[1][2]*A[2][1])-A[0][1]*(A[1][0]*A[2][2]-A[1][2]*A[2][0])+A[0]
[2]*(A[1][0]*A[2][1]-A[1][1]*A[2][0]));

printf("\n The determinant of matrix:%f",detA);

if(detA==0)

printf("\nThe matrix is singular.");

printf("\n The inverse does not exist.");

else

cofA[0][0]=A[1][1]*A[2][2]-A[1][2]*A[2][1];

cofA[0][1]=(-1)*(A[1][0]*A[2][2]-A[1][2]*A[2][0]);

cofA[0][2]=A[1][0]*A[2][1]-A[1][1]*A[2][0];

cofA[1][0]=(-1)*(A[0][1]*A[2][2]-A[0][2]*A[2][1]);
cofA[1][1]=A[0][0]*A[2][2]-A[0][2]*A[2][0];

cofA[1][2]=(-1)*(A[0][0]*A[2][1]-A[0][1]*A[2][0]);

cofA[2][0]=A[0][1]*A[1][2]-A[0][2]*A[1][1];

cofA[2][1]=(-1)*(A[0][0]*A[1][2]-A[1][0]*A[0][2]);

cofA[2][2]=A[1][1]*A[0][0]-A[1][0]*A[0][1];

printf("\n The cofactor of matrix:A\n\n");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

printf("%d\t",cofA[m][n]);

printf("\n");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

adjA[m][n]=cofA[n][m];

printf("\n The adjoint of matrix A:\n\n");


for(m=0;m<3;m++)

for(n=0;n<3;n++)

printf("%d\t",adjA[m][n]);

printf("\n");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

invA[m][n]=(1/detA)*(adjA[m][n]);

printf("\n The inverse of matrix A:\n\n");

for(m=0;m<3;m++)

for(n=0;n<3;n++)

printf("%.3f\t",invA[m][n]);

printf("\n");

}
getch();

OUTPUT

Enter the elements of matrix : -2 -2 7 4 3 -12 -1 0 2

The entered matrix is:

-2 -2 7

4 3 -12

-1 0 2

The determinant of matrix:1.000000

The cofactor of matrix:A

6 4 3

4 3 2

3 4 2

The adjoint of matrix A:

6 4 3

4 3 4

3 2 2

The inverse of matrix A:


6.000 4.000 3.000

4.000 3.000 4.000

3.000 2.000 2.000

/* Develope and exacute a program to obtain a value of an equation using subroutaine*/

#include<stdio.h>

#include<conio.h>

main()

float area();

area();

area()

int A,l;

printf("OUTPUT")

printf("Enter the value of side");


scanf("%d",&l);

A=l*l;

printf("The area of square=%d",A);

getch();

/* Develope and exacute a program to obtain a value of an equation using subroutaine*/

#include<stdio.h>

#include<conio.h>

main()

float area();

area();

area()

int A,l;

printf("OUTPUT");

printf("Enter the value of side");

scanf("%d",&l);

A=l*l;

printf("The area of square=%d",A);

getch();

OUTPUTEnter the value of side5


The area of square=25

You might also like