// WAP to enter three coefficient of quadratic equation and find the roots. #include<stdio.h> #include<conio.h> #include<math.h> void main() { float a,b,c,d,x1=0,x2=0; clrscr(); printf("Enter coefficient of x2:\n"); scanf("%f",&a); printf("Enter coefficient of x:\n"); scanf("%f",&b); printf("Enter constant:\n"); scanf("%f",&c); d=(b*b-4*a*c); x1=(-b+sqrt(d))/(2*a); x2=(-b-sqrt(d))/(2*a); printf("x1 = %f\n",x1); printf("x2 = %f\n",x2); getch(); }
// WAP to enter three numbers and find middle number among them. #include<stdio.h> #include<conio.h> void main ( ) { int a , b , c ; clrscr ( ) ; printf ( "Enter three number: \n " ) ; scanf ( "%d%d%d" ,& a ,& b ,& c ) ; if ( ( a > b && a < c ) || ( a > c && a < b ) ) printf ( "%d is middle number" , a ) ; else if ( ( b > a && b < c ) || ( b > c && b < a ) ) printf ( "%d is middle number" , b ) ; else printf ( "%d is middle number" , c ) ; getch ( ) ; } Output:
Comments
Post a Comment