The polar coordinates r and 9 of a point (x, y) in the plane can be computed as follows: √x² + y² 0= { T= acos(r/r) -acos(x/r) 0 if r> 0 and y>0 if r> 0 and y≤0 ifr=0 Write a program which uses a function called polar() to compute the polar coordinates of a point. Your program must consist of a main program and a function called polar. The function polar () takes the r and y coordinates of a point as arguments and computes the polar coordinates (r, 0). The main program opens the output file polarout.txt for appending (mode="a"), reads the (x, y) coordinates from the keyboard, calls polar (), and then writes both the (x, y) coordinates and the corresponding (r, 0) polar coordinates to the output file. The first (and subsequent) lines of your output should look like: The polar coordinates of (2.0000, 2.0000) are r = 2.8284 and theta = 0.7854 For marking purposes run your program 4 times with (x, y) as follows: (2,2), (1,-1), (0,1) and (3,-1).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Plz solve the question using c programming without changing or adding any other library other than the library # include < stdio.h >, the second photo is a sample of how the coding should look like
#include<stdio.h>
#include<math.h>
float f(float x);
float df (float x):
void newton (float x1, float tol, float* add_root, int" add_iter);
int main(void) {
float x1, tol, root;
int iter;
FILE" fout = fopen("rootsout.txt", "a");
printf("Enter the starting guess and the desired tolerance: ");
scanf("%f%f", 8x1, Stol);
newton (x1, tol, Broot,&iter);
fprintf(fout, "After %d iterations the estimated root near XF is: f\n", iter, x1, root);
fclose(fout);
return;
float (float x){
float yi
y = sin(x)-2.0*exp(-x);
return y;
float df (float x){
float yi
y = cos(x)+2.€*exp(-x);
return y;
}
}
void newton (float x1, float tol, float" add_root, int* add_iter){
float x2;
int iter=;
while(1){
x2 = x1 *(x1)/df(x1);
if (fabs (x2-x1)<tol){
break;
}
x2=x2;
"add_root = x2;
add_iter = iter;
return;
Transcribed Image Text:#include<stdio.h> #include<math.h> float f(float x); float df (float x): void newton (float x1, float tol, float* add_root, int" add_iter); int main(void) { float x1, tol, root; int iter; FILE" fout = fopen("rootsout.txt", "a"); printf("Enter the starting guess and the desired tolerance: "); scanf("%f%f", 8x1, Stol); newton (x1, tol, Broot,&iter); fprintf(fout, "After %d iterations the estimated root near XF is: f\n", iter, x1, root); fclose(fout); return; float (float x){ float yi y = sin(x)-2.0*exp(-x); return y; float df (float x){ float yi y = cos(x)+2.€*exp(-x); return y; } } void newton (float x1, float tol, float" add_root, int* add_iter){ float x2; int iter=; while(1){ x2 = x1 *(x1)/df(x1); if (fabs (x2-x1)<tol){ break; } x2=x2; "add_root = x2; add_iter = iter; return;
The polar coordinates r and 0 of a point (x, y) in the plane can be computed as follows:
√x² + y²
72
0-
T=
acos(x/r) if r> 0 and y > 0
-acos(x/r) if r > 0 and y ≤ 0
0
Write a program which uses a function called polar() to compute the polar coordinates of
a point. Your program must consist of a main program and a function called polar. The
function polar() takes the r and y coordinates of a point as arguments and computes the
polar coordinates (r, 0). The main program opens the output file polarout.txt for appending
(mode "a"), reads the (x, y) coordinates from the keyboard, calls polar (), and then writes
both the (x, y) coordinates and the corresponding (7, 8) polar coordinates to the output file.
The first (and subsequent) lines of your output should look like:
The polar coordinates of (2.0000, 2.0000) are = 2.8284 and theta = 0.7854
1
For marking purposes run your program 4 times with (x, y) as follows: (2,2), (1,-1),
(0,1) and (3,-1).
Transcribed Image Text:The polar coordinates r and 0 of a point (x, y) in the plane can be computed as follows: √x² + y² 72 0- T= acos(x/r) if r> 0 and y > 0 -acos(x/r) if r > 0 and y ≤ 0 0 Write a program which uses a function called polar() to compute the polar coordinates of a point. Your program must consist of a main program and a function called polar. The function polar() takes the r and y coordinates of a point as arguments and computes the polar coordinates (r, 0). The main program opens the output file polarout.txt for appending (mode "a"), reads the (x, y) coordinates from the keyboard, calls polar (), and then writes both the (x, y) coordinates and the corresponding (7, 8) polar coordinates to the output file. The first (and subsequent) lines of your output should look like: The polar coordinates of (2.0000, 2.0000) are = 2.8284 and theta = 0.7854 1 For marking purposes run your program 4 times with (x, y) as follows: (2,2), (1,-1), (0,1) and (3,-1).
Expert Solution
Step 1

C Introduction:-

Dennis M. Ritchie created the imperative, procedural, general-purpose C language for the UNIX OS in 1972 while working at Bell Telephone. Along with Java, which is primarily utilised by contemporary programmers, the C language is currently one of the most popular computer languages.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education