C Program To Convert Radian To Degree

Lets write a C program to convert angle from Radian to Degree.

Formula To Convert Radian To Degree

degree = radian x (180.0 / M_PI);

where M_PI is a constant present in header file / library file math.h and its approximately equal to 3.14;

Related Read:
Keywords, Constants, Variables: C
Basic Arithmetic Operations In C
Print All Trigonometric Ratios: C Program
C Program To Convert Degree To Radian

Video Tutorial: C Program To Convert Radian To Degree


[youtube https://www.youtube.com/watch?v=U9y2bnDY4kE]

YouTube Link: https://www.youtube.com/watch?v=U9y2bnDY4kE [Watch the Video In Full Screen.]

Source Code: C Program To Convert Radian To Degree

#include<stdio.h>
#include<math.h>

int main()
{
    float radian, degree;

    printf("Enter angle in Radian\n");
    scanf("%f", &radian);

    degree = radian * ( 180.0 / M_PI );

    printf("Angle in Degree is %f\n", degree);

    return 0;
}

Output 1:
Enter angle in Radian
1
Angle in Degree is 57.295780

Output 2:
Enter angle in Radian
5
Angle in Degree is 286.478912

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Convert Degree To Radian

Lets write a C program to convert angle from Degree to Radian.

Formula To Convert Degree To Radian

radian = degree x (M_PI / 180.0);

where M_PI is a constant present in header file / library file math.h and its approximately equal to 3.14;

Note: Trigonometric Ratios like Sin, Cos, Tan etc take radian value as input and not degrees. So its important to learn how to convert angles from degree to radian.

Related Read:
Keywords, Constants, Variables: C
Basic Arithmetic Operations In C
Print All Trigonometric Ratios: C Program
C Program To Convert Radian To Degree

Video Tutorial: C Program To Convert Degree To Radian


[youtube https://www.youtube.com/watch?v=3h9iUUlqTlA]

YouTube Link: https://www.youtube.com/watch?v=3h9iUUlqTlA [Watch the Video In Full Screen.]

Source Code: C Program To Convert Degree To Radian

#include<stdio.h>
#include<math.h>

int main()
{
    float degree, radian;

    printf("Enter angle in Degrees\n");
    scanf("%f", &degree);

    radian = degree * ( M_PI / 180.0 );

    printf("Angle in Radian is %f\n", radian);

    return 0;
}

Output 1:
Enter angle in Degrees
90
Angle in Radian is 1.570796

Output 2:
Enter angle in Degrees
360
Angle in Radian is 6.283185

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Check If Sum of Square of Sine and Cosine of an Angle is 1

Write a C program to receive value of an angle in degrees and check whether sum of squares of sine and cosine of this angle is equal to 1.

Related Read:
Basic Arithmetic Operations In C
Calculate Power of a Number using pow(): C Program

Formula To Convert Angle From Degree To Radian

radian = degree x ( PI / 180.0)
where PI is 3.14159265359

Note: In C programming Language, we’ve a builtin constant M_PI which has value of PI.

Expected Output for the Input

User Input:
Enter angle in Degree
45

Output:
Sum of square of sin(45.00) and cos(45.00) is 1

Logic To Check If Sum of Square of Sine and Cosine of an Angle is 1

User enters the angle in degree. We convert angle from degree to radian.
radian = degree x ( PI / 180.0)
Next we use pow() method present in math.h library to sqaure the values of sin(angle) and cos(angle). We add the square of sin(angle) and cos(angle) and store it inside the variable sum, and display appropriate message to the user.

Video Tutorial: C Program To Check If Sum of Square of Sine and Cosine of an Angle is 1


[youtube https://www.youtube.com/watch?v=wYbhYLcAv3Y]

YouTube Link: https://www.youtube.com/watch?v=wYbhYLcAv3Y [Watch the Video In Full Screen.]

Source Code: C Program To Check If Sum of Square of Sine and Cosine of an Angle is 1

#include<stdio.h>
#include<math.h>

int main()
{
    float sum = 0, angle, temp;

    printf("Enter angle in Degree\n");
    scanf("%f", &angle);

    temp   = angle;

    angle  = angle * ( M_PI / 180.0 );

    sum    = (  pow(sin(angle), 2) + pow(cos(angle), 2)  );

    if(sum == 1)
    {
        printf("Sum of square of sin(%0.2f) and cos(%0.2f) is 1\n", temp, temp);
    }
    else
    {
        printf("Sum of square of sin(%0.2f) and cos(%0.2f) is not 1\n", temp, temp);
    }

    return 0;
}

Output 1:
Enter angle in Degree
30
Sum of square of sin(30.00) and cos(30.00) is 1

Output 2:
Enter angle in Degree
45
Sum of square of sin(45.00) and cos(45.00) is 1

Output 3:
Enter angle in Degree
60
Sum of square of sin(60.00) and cos(60.00) is 1

Output 4:
Enter angle in Degree
75
Sum of square of sin(75.00) and cos(75.00) is 1

Output 5:
Enter angle in Degree
90
Sum of square of sin(90.00) and cos(90.00) is 1

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Convert Polar To Cartesian Co-ordinates

Write a C program to receive Polar co-ordinates(r, θ) and convert them into Cartesian co-ordinates(x, y). Ask the user to enter theta(θ) value in degrees.

Related Read:
C Program To Convert Cartesian To Polar Co-ordinates

Formula To Convert Polar To Cartesian Co-ordinates

x = r * cos(θ);

y = r * sin(θ);

where x and y are Cartesian co-ordinates. r and θ are polar co-ordinates.

Formula To Convert Degree To Radian

radian = degree * (PI/180.0);
where PI is 3.141592

Source Code: Convert Polar To Cartesian Co-ordinates: C Program

 
#include < stdio.h >
#include < math.h >

int main()
{
    float x, y, r, theta;
    const float PI = 3.141592;

    printf("Enter Polar Co-ordinates(r, theta)\n");
    scanf("%f%f", &r, &theta);

    /* Convert angle from Degree To Radian */    theta = theta * (PI / 180.0); 

    x = r * cos(theta);
    y = r * sin(theta);

    printf("Cartesian Co-ordinates (x, y) = (%f, %f)\n", x, y);

    return 0;
}

Output:
Enter Polar Co-ordinates(r, theta)
5.01
53.131
Cartesian Co-ordinates (x, y) = (3.005938, 4.008047)

Convert Polar To Cartesian Co-ordinates: C Program


[youtube https://www.youtube.com/watch?v=XCz3CDUsC9o]

YouTube Link: https://www.youtube.com/watch?v=XCz3CDUsC9o [Watch the Video In Full Screen.]


For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Convert Cartesian To Polar Co-ordinates

Write a C program to receive Cartesian co-ordinates(x, y) of a point and convert them into Polar co-ordinates(r, θ).

Related Read:
C Program To Convert Polar To Cartesian Co-ordinates

Formula To Convert Cartesian To Polar Co-ordinates

r = sqrt(x*x + y*y);
OR
r = sqrt( pow(x, 2) + pow(y, 2) );

theta(θ) = atan(y/x);

where x and y are Cartesian co-ordinates.
atan() is the method in math.h library for calculating tan inverse.

Formula To Convert Radian To Degree

degree = radian * (180.0 / PI);
where PI is 3.141592

Source Code: Convert Cartesian To Polar Co-ordinates: C Program

 
#include < stdio.h >
#include < math.h >

int main()
{
    float x, y, r, theta;
    const float PI = 3.141592;

    printf("Enter Cartesian Co-ordinates(x, y)\n");
    scanf("%f%f", &x, &y);

    r     = sqrt(x*x + y*y);
    theta = atan(y/x);       // Radian

    theta = theta * (180.0 / PI); //Radian To Degree Conversion

    printf("Polar Co-ordinates: (r, theta) = (%f, %f)\n", r, theta);

    return 0;
}

Output:
Enter Cartesian Co-ordinates(x, y)
3
4
Polar Co-ordinates: (r, theta) = (5.000000, 53.130112)

Convert Cartesian To Polar Co-ordinates: C Program


[youtube https://www.youtube.com/watch?v=3ebGfJ_GOD0]

YouTube Link: https://www.youtube.com/watch?v=3ebGfJ_GOD0 [Watch the Video In Full Screen.]


For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert