Chapter - 2: C Instructions

Write a program to receive cartesian coordinates (x,y) of a point and convert them into polar coordinates. (r,theta)


H
Sections
7
Exercises

A

B

C

D

E

F

G

H

1

2

3

4

5

6

7

8

9

10

#include<stdio.h>>
#include<conio.h>
#include<math.h>
int main()
{
	float x, y, r, theta;
	
	printf("Enter the x and y coordinates : ");
	scanf("%f%f", &x, &y);
	
	r = sqrt(x*x + y*y);
	theta = atan(y/x);
	//atan() is a function to find the tan inverse
	
	printf("\nCoordinates in polar form : %.2f(cos(%.2f) + i.sin(%.2f))", r, theta, theta);
	//%.2f means only two decimal palces will be printed.
	
	getch();
	return 0;
}

© 2020 Garbage Valuegarbage value logo