Program:
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,alpha,beta,delta,realpart,imaginarypart;
printf("Enter a,b and c: \n");
scanf("%f %f %f",&a,&b,&c);
delta=(b*b)-(4*a*c);
if(delta==0)
{
printf("alpha=beta=%f",-b/(2*a));
}
else if(delta<0)
{
realpart=-b/(2*a);
imaginarypart=(sqrt(-delta))/(2*a);
printf("alpha=%f+%fi \n beta=%f-%fi\n",realpart,imaginarypart,realpart,imaginarypart);
}
else
{
alpha=(-b+sqrt(delta))/(2*a);
beta=(-b-sqrt(delta))/(2*a);
printf("alpha=%f \n beta=%f\n",alpha,beta);
}
return 0;
}
Output:
#include<stdio.h>
#include<math.h>
int main()
{
float a,b,c,alpha,beta,delta,realpart,imaginarypart;
printf("Enter a,b and c: \n");
scanf("%f %f %f",&a,&b,&c);
delta=(b*b)-(4*a*c);
if(delta==0)
{
printf("alpha=beta=%f",-b/(2*a));
}
else if(delta<0)
{
realpart=-b/(2*a);
imaginarypart=(sqrt(-delta))/(2*a);
printf("alpha=%f+%fi \n beta=%f-%fi\n",realpart,imaginarypart,realpart,imaginarypart);
}
else
{
alpha=(-b+sqrt(delta))/(2*a);
beta=(-b-sqrt(delta))/(2*a);
printf("alpha=%f \n beta=%f\n",alpha,beta);
}
return 0;
}
Output:
No comments:
Post a Comment