0% found this document useful (0 votes)
79 views

Q1Write A C Program To Find Roots of A Quadratic Equation. Program Coding

The document contains 3 questions asking to write C programs: 1) To find the roots of a quadratic equation by taking user input for variables x and y and performing calculations to find the value of an expression. 2) To convert 2 given algebraic expressions into equivalent C code by defining variables, performing calculations, and printing the final answer. 3) To receive Cartesian coordinates (x,y) as input, calculate the polar coordinates (r,φ) using trigonometric functions, and print the results.

Uploaded by

Hamza Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views

Q1Write A C Program To Find Roots of A Quadratic Equation. Program Coding

The document contains 3 questions asking to write C programs: 1) To find the roots of a quadratic equation by taking user input for variables x and y and performing calculations to find the value of an expression. 2) To convert 2 given algebraic expressions into equivalent C code by defining variables, performing calculations, and printing the final answer. 3) To receive Cartesian coordinates (x,y) as input, calculate the polar coordinates (r,φ) using trigonometric functions, and print the results.

Uploaded by

Hamza Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy