Q1Write a C program to find roots of a quadratic equation.
Program coding
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,y,temp1,temp2,temp3;
clrscr();
printf("Enter the variables x and y\n");
scanf("%f%f",&x,&y);
temp1=(x+3)*pow(x,3);
temp2=(y-4)*(y+5);
temp3=temp1/temp2;
printf("The value of expression is %f\n",temp3);
getch();
}
Output
Q2) Convert the following algebraic expressions into equivalent C
statements:
(A)
(𝑥 + 3)𝑥 3
𝑍=
(𝑦 − 4)(𝑦 + 5)
Program Coding
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,y,temp1,temp2,temp3;
clrscr();
printf("Enter the variables x and y\n");
scanf("%f%f",&x,&y);
temp1=(x+3)*pow(x,3);
temp2=(y-4)*(y+5);
temp3=temp1/temp2;
printf("The value of expression is %f\n",temp3);
getch();
}
Output
(B)
2𝑣 + 6.22(𝑐 + 𝑑)
𝑅=
𝑔+𝑣
Program Coding
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
float v,c,d,g,temp1,temp2,final;
clrscr();
printf("Enter the values\n");
scanf("%f%f%f%f%f",&v,&c,&d,&g,&v);
temp1=2*v+6.22*(c+d);
temp2=g+v;
final=temp1/temp2;
printf("The final answer is %f\n",final);
getch();
}
Output
C)
7.7𝑏(𝑥𝑦 + 𝑎)
− 0.8 + 2𝑏
𝐴= 𝑐
1
(𝑥 + 𝑎)( )
𝑦
Program Coding
#include<stdio.h>
#include<conio.h>
void main()
{
float x,y,a,b,c,t1,t2,t3,t4,t5,final;
clrscr();
printf("Enter the values of variable \n");
scanf("%f%f%f%f%f",&x,&y,&a,&b,&c);
t1=b*7.7;
t2=(x*y)+a;
t3=(t1*t2)/c;
t4=t3-0.8+2*b;
t5=(x+a)/y;
final=t4/t5;
printf("The result is %f\n",final);
getch();
}
Output
Q3) Write a program to receive Cartesian co-ordinates (x,y) of a point and
convert them into polar co-ordinates(r,ⱷ).
𝑦
Hint: 𝑟 = 𝑠𝑞𝑟𝑡(𝑥 2 + 𝑦 2 )𝑎𝑛𝑑 𝜑 = tan−1 ⁄𝑥
Program coding
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
float x,y,z,j,polx,poly;
clrscr();
printf("Enter the coordinates\n");
scanf("%f%f",&x,&y);
j=y/x;
x=x*x;
y=y*y;
z=x+y;
polx=sqrt(z);
poly=atan(j);
printf("The Polar form is %f%f\n",polx,poly);
getch();
}
Output