Facebook
Banner
XMPP JavaScript Library READ MORE

Program to find the roots of a quadratic equation.

Program to find the roots of a quadratic equation.

1 /*program to find the roots of a quardatic equation*/
2 #include <stdio.h>
3 #include <math.h>
4 #include <conio.h>
5
6 /*Function to calculate the roots of quardatic*/
7 void quadaratic_root(int a,int b,int c)
8 {
9 double x,y;
10 printf("\n");
11 x=(-b+(pow(pow(b,2)-4*a*c,.5)))/(2*a);
12 y=(-b-(pow(pow(b,2)-4*a*c,.5)))/(2*a);
13
14 printf("%lf and %lf",x,y);
15 }
16 void main()
17 {
18 int a,b,c;
19 printf("Enter value for a: ");
20 scanf("%d",&a);
21
22 printf("Enter value for b: ");
23 scanf("%d",&b);
24
25 printf("Enter value for c: ");
26 scanf("%d",&c);
27
28 if(pow(b,2)-4*a*c<0)
29 {
30 printf("Roots can't be find");
31 }
32 else if(pow(b,2)-4*a*c==0)
33 {
34 printf("Single Root");
35 quadaratic_root(a,b,c);
36 }
37 else if(pow(b,2)-4*a*c>0)
38 {
39 printf("Double Root");
40 quadaratic_root(a,b,c);
41 }
42 getch();
43 }
Add Your Comment
   
    Yes! I want to receive all comments by email

  by elakkiya on 28-Sep-2014 02:26 pm
thankyou&bye
  • Reply
  •  0 Like
  •  1 Dislike
  • Report
  by xyz on 28-Sep-2014 02:24 pm
good
  • Reply
  •  0 Like
  •  1 Dislike
  • Report
  by vijay tembre on 22-May-2011 09:50 am
the program is very usefull for the first year BE Students for computer programming subject......One more thing pls tell me download or copy paste the videos in video section.....vijay tembre BE(Production)
  • Reply
  •  5 Like
  •  4 Dislike
  • Report
  by Sachin Puri on 30-May-2011 08:52 pm
Sorry to reply you late. Thanks for liking the content. If you want to publish any content on this site you can male me that at mail@sachinpuri.com
  • Reply
  •  4 Like
  •  4 Dislike
  • Report