.
//Quadratic
equation
#include<iostream.h>
#include<conio.h>
#include<math.h>
void
main()
{
clrscr();
int
a,b,c,d;
float
rt1,rt2;
cout<<"Enter
the values of a, b, c (Coefficients):";
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d==0)
{
cout<<"Roots are real
& equal:";
rt1=rt2=-b/(2*a);
cout<<rt1<<","<<rt2;
}
else
if(d>0)
{
cout<<"Roots are real
& unequal:";
rt1=(-b+sqrt(d))/2*a;
rt2=(-b-sqrt(d))/2*a;
cout<<rt1<<","<<rt2;
}
else
cout<<"Routs are
imaginary:";
getch();
}
3. Program
to check whether the year is leap year or not
//Leap
year
#
include<iostream.h>
#include<conio.h>
void
main ()
{
int
yr;
clrscr
();
cout<<"Enter
a year in four digits:";
cin>>yr;
if
((yr%4==0 &&yr%100!=0) || (yr%400==0))
cout<<"It is a leap
year";
else
cout<<"It is not a leap
year";
getch
();
}
No comments:
Post a Comment