You are on page 1of 37

PROGRAM 1

1) Write a program largest out of 3 number entered by student using if else


statement .
#include<conio.h>

#include<stdio.h>

void main()

clrscr();

int t,i,h;

printf("\n\n Enter the value of 't' number =" );

scanf("%d",&t);

printf("\n\n Enter the value of 'i' number =" );

scanf("%d",&i);

printf("\n\n Enter the value of 'h' number =" );

scanf("%d",&h);

if (h>t&&h>i)

printf("\n\n the greatest number is = %d",h);

else

if(i>h&&i>t)

printf("\n\n the greatest number is 'i'= %d",i);

}
else

printf("\n\n the greatest number is 't' = %d",t);

getch();

OUTPUT :
PROGRAM 2
2) Write a program largest out of 10 number entered by student .
#include<conio.h>

#include<stdio.h>

void main()

clrscr();

int t,i,h=0;

for(i=1;i<=10;i++)

printf("\n\n Enter the value of 't' number =" );

scanf("%d",&t);

if (h>t)

h;

else

h=t;

printf("\n\n the greatest number is = %d",h);

getch();

}
OUTPUT :
PROGRAM 3
3) Write a program to find avreage of male and female height in a class.
#include<conio.h>

#include<stdio.h>

void main()

clrscr();

int t,i,h,sum1=0,sum2=0,f=0,m=0;

float avg1,avg2;

printf("\n Enter the total number of a students =");

scanf("%d",&t);

for(i=1;i<=t;i++)

printf("\n Enter the height of a students =");

scanf("%d",&h);

if (h<6)

printf("\nthe height of a girls =%d",h);

sum2 +=h;

++f;

else

printf("\n the height of a boys =%d",h);


sum1 +=h;

++m;

avg1=sum1/m;

avg2=sum2/f;

printf("\n the average of boys(male) height is = %f",avg1);

printf("\n the average of girls(female) height is = %f",avg2) ;

getch();

}
OUTPUT :
PROGRAM 4
4) Write a program to find roots of quadratic equation.
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main()

clrscr();

int a,c,b,D,x;

float x1,x2;

printf("\nenter the value of 'a'=") ;

scanf("%d",&a);

printf("\nenter the value of 'b'=") ;

scanf("%d",&b);

printf("\nenter the value of 'c'=") ;

scanf("%d",&c);

D = b*b - 4*a*c;

printf("\n\nthe value of D is= %d",D);

printf("\n\n\n enter 1 : for if D > 0\n\n\nenter key 2 : if D == 0\n\n\n enter key 3 : if D <
0\n\n\n\n where x1 & x2 are roots ") ;

printf ("\n\n\nenter your choice from 1-3 = ");

scanf("%d",&x);

switch (x)

{
case 1:

printf ("\n\n\n\n roots are real");

x1 = - b + sqrt(D)/2*a;

x2 = - b - sqrt(D)/2*a;

printf ("\n\n\n\nthe value of root x1 = %f",x1);

printf ("\n\n\n\nthe value of root x2 = %f",x2);

break;

case 2:

x1 = - b + sqrt(D)/2*a;

x2 = - b - sqrt(D)/2*a;

printf ("\n\n\n\nthe value of root x1 = %f",x1);

printf ("\n\n\n\nthe value of root x2 = %f",x2);

break;

case 3:

x1 = - b + sqrt(D)/2*a;

x2 = - b - sqrt(D)/2*a;

printf ("\n\n\nroots are imaginary");

printf ("\n\n\n\nthe value of root x1 = %f",x1);

printf ("\n\n\n\nthe value of root x2 = %f",x2);

break;

default :

printf("you enter the the wrong number");

getch();
OUTPUT :
PROGRAM FILE
OF
FUNDAMENTAL COMPUTER
&
IN C

NAME : sachin
BRANCH : mechanical-a2
PROGRAMME : b.tech( 1 sem)
st

Submitted to : ER . SONAM S HARMA


S I G N A T U R E : ____________
PROGRAM – 5
1) To find average of five number.
#include<stdio.h>

#include<conio.h>

void main()

int a,b,c,d,e,sum;

float average;

printf("enter five numbers");

scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

sum=a+b+c+d+e;

average=sum/5;

printf("sum is%d",sum);

printf("average=%f",average);

Output :
PROGRAM 6
1)Find the largest number out of three number.
#include<stdio.h>

#include<conio.h>

void main()

int a,b,c;

printf("enter the value of a,b,c");

scanf("%d%d%d",&a,&b,&c);

if(a>b&&a>c)

printf("a is largest");

else if(b>c)

printf("b is largest");

else

printf("c is lergest");

getch();

}
PROGRAM 7
1)Write a program multiple one matrix to another matrix.
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main ()

int a[3][3],b[3][3],c[3][3];

int i,j,k;

for(i=1;i<=3;i++)

for(j=1;j<=3;j++)

scanf("%d",&a[i][j]);

for(i=1;i<=3;i++)

for(j=1;j<=3;j++)

scanf("%d",&b[i][j]);

for(i=1;i<=3;i++)

for(j=1;j<=3;j++)

{
c[i][j]=0;

for(k=1;k<=3;k++)

c[i][j]=c[i][j]+a[i][j]*b[k][j];

printf("\n\n\

%d",c[i][j]);

getch();

You might also like