Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/AminproPastebin
- // October 2011
- // Question 1 (b)
- #include <stdio.h>
- #include <math.h>
- int main(){
- int a, b, c;
- float x1, x2;
- printf("<--------- Program Starts ---------->\n\n");
- printf("Enter coefficients a, b and c of quadratic equation: ");
- scanf("%d%d%d", &a, &b, &c);
- if( (((b)^2)-(4*a*c)) > 0 ){
- if(a != 0){
- x1 = ((-b)-(sqrt((b^2)-(4*a*c))))/(2*a);
- x2 = ((-b)+(sqrt((b^2)-(4*a*c))))/(2*a);
- printf("The solutions are %.2f, %.2f\n\n", x2, x1 );
- }
- else
- printf("Error a ==0\n\n");
- }
- else printf("The eqn has no real solution : b^2 - 4ac < 0\n\n");
- printf("<--- Program Ends and Terminates --->\n");
- getchar();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement