How To Solve Quadratic Equations Using C language
Quadratic Equation Using C Language
Now in this tutorial before going on code i have to sort out some things which will help the new bie programmers to do it .
I have include three following files in the header like
#include<stdio.h> -------------------> This is the standard input output file
#include<conio.h> -------------------> This is the console file for output on the screen
#include<math.h> --------------------> This is the math header file to solve mathematics function
Now there are escape sequences and format specifier in the c language that which you have to learn about that
int -----> this is the keyword for integer type data.
Examples like int a,b;
float ----> this is the keyword for float type data
Example like float a,b;
Now if you want to display the code into the program you have to use format specifier to display the code
%d is the format specifier for integer type value
%f is the format specifier for float type value
I have used different variable name in this program.
Through this code you can solve the quadratic equation
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void)
{
float a,b,c,y,x,z,t,u,v,w;
clrscr();
printf("*************** Quadratic Equation ***************************\n");
printf(" \n Plz enter the value of a : ");
scanf("%f",&a);
printf(" \n Please enter the value of b :");
scanf("%f",&b);
printf(" \n Please enter the value of c :");
scanf("%f",&c);
x=pow(b,2);
y=4*a*c;
z=x-y;
u=sqrt(z);
t=-b+u;
v=t/(2*a);
printf("The Answer is = %f",v);
w=-b-u;
printf("The Answer is = %f",w);
getch();
}
No comments:
Post a Comment