Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Iterative statement



Test expression



Specifer



" ; " after loop



Header file




Calculate roots of quadratic equation



// AHF C PROGRAM SOLVING

//solving here basic type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int a,b,c; float root1,root2,p1,p2; pf("Enter the value of a,b and c: "); scanf("%d %d %d",&a,&b,&c); p1= pow(b,2)-(4*a*c); p2=2*a; if(p1>0) { pf("\nREAL ROOTS."); root1=(-b+sqrt(p1))/p2; root2=(-b-sqrt(p1))/p2; pf("\nROOT1= %f\tROOT2= %f",root1,root2); } else if(p1==0) { pf("\nEQUAL ROOTS."); root1=-b/p2; pf("\nROOT1= %f",root1); } else pf("\nMIGENARY ROOTS."); return 0; }
OUTPUT:


© 2018 - All rights reserved