More Related Content
Similar to Control Structures
Similar to Control Structures (20)
More from Ghaffar Khan (20)
Control Structures
- 13. The if-else statement: (Example 7.3 Quadratic Equation )
- 14. The if-else statement: (Example 7.3 Quadratic Equation ) #include <stdio.h> #include <conio.h> #include <math.h> void main(void) { int a, b, c; double d, x1, x2; //clrscr(); printf("Input a="); scanf("%d",&a); printf("input b = "); scanf("%d",&b ); printf("input c = "); scanf("%d",&c ); d = b*b -4*a*c; if (d<0) { printf("Roots are not real"); printf("Enter some other values of a, band c"); } else { x1 = ( -b - sqrt( d )) / (2 * a); x2 = ( -b + sqrt( d )) / (2 * a); printf("First Root is %.2f",x1); printf("Second Root is %.2f",x2); } getch(); }