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 Convert Pounds to Kilograms

Lets write a C program to Convert weight from Pounds to Kilograms.

Note: 1 Pound is approximately equal to 0.453592 Kilogram.

pound to kilogram

Formula To Convert Weight From Pounds to Kilograms

kilogram = pound * 0.453592;

OR

From our previous video tutorial C Program To Convert Kilograms to Pounds

pound = kilogram * 2.20462;
pound / 2.20462 = kilogram;
kilogram = pound / 2.20462;

Related Read:
Keywords, Constants, Variables: C
Basic Arithmetic Operations In C

Logic To Convert Pounds to Kilograms

First we ask the user to enter weight / mass in pounds. Then we multiply that value with 0.453592. The result itself is the Kilograms equivalent of user entered weight in pound.

Video Tutorial: C Program To Convert Pounds to Kilograms


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

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

Source Code: C Program To Convert Pounds to Kilograms

#include<stdio.h>

int main()
{
    const float KG = 0.453592;
          float pound;

    printf("Enter weight in pounds\n");
    scanf("%f", &pound);

    printf("Weight in Kilograms is %f\n", (pound * KG) );

    return 0;
}

Output 1:
Enter weight in pounds
11
Weight in Kilograms is 4.989512

Output 2:
Enter weight in pounds
11.04
Weight in Kilograms is 5.007656

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 Calculate Distance Between Two Points

Given two points A(x1, y1) and B(x2, y2), find the distance between them.

Formula To Calculate Distance Between Two Points using Pythagorean theorem

distance = sqrt( (x2 – x1) * (x2 – x1) + (y2 – y1) * (y2 – y1) );

Note: sqrt() is a builtin method present in math.h header file.

Related Read:
Basic Arithmetic Operations In C

Expected Output for the Input

User Input:
Enter point 1 (x1, y1)
1
1
Enter point 2 (x2, y2)
9
9

Output:
Distance between (1.00, 1.00) and (9.00, 9.00) is 11.31

Video Tutorial: C Program To Calculate Distance Between Two Points


[youtube https://www.youtube.com/watch?v=e4R-VhXp_k4]

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

Source Code: C Program To Calculate Distance Between Two Points

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

int main()
{
    float x1, y1, x2, y2, distance;

    printf("Enter point 1 (x1, y1)\n");
    scanf("%f%f", &x1, &y1);

    printf("Enter point 2 (x2, y2)\n");
    scanf("%f%f", &x2, &y2);

    distance = sqrt( (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1) );

    printf("Distance between (%0.2f, %0.2f) and (%0.2f, %0.2f) is %0.2f\n", x1, y1, x2, y2, distance);

    return 0;
}

Output 1:
Enter point 1 (x1, y1)
0
0
Enter point 2 (x2, y2)
5
0
Distance between (0.00, 0.00) and (5.00, 0.00) is 5.00

Output 2:
Enter point 1 (x1, y1)
2
3
Enter point 2 (x2, y2)
10
8
Distance between (2.00, 3.00) and (10.00, 8.00) is 9.43

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 Calculate Surface Area of Sphere

Given the value for radius of a Sphere, write a C program to calculate Surface Area of the Sphere.

Formula To Calculate Surface Area of Sphere

When radius value is known: Area = 4 * π * radius²,
When diameter value is known: Area = π * diameter²,
When volume value is known: Area = ³√(36 * π * Volume²).

where π (PI) is approximately equal to 3.14

surface area of sphere

Related Read:
Basic Arithmetic Operations In C

Logic To Calculate Surface Area of Sphere

We ask the user to enter the value of radius of the sphere. We apply the formula:
Surface_ Area = 4 * PI * radius2
where π (PI) is approximately equal to 3.14

Expected Output for the Input

User Input:
Enter Radius of the Sphere
5

Output:
Surface Area of Sphere is 314.000000

Video Tutorial: C Program To Calculate Surface Area of Sphere


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

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

Source Code: C Program To Calculate Surface Area of Sphere

#include<stdio.h>

int main()
{
    const float PI = 3.14;
          float r, area;

    printf("Enter Radius of the Sphere\n");
    scanf("%f", &r);

    area = ( 4 * PI * r * r );

    printf("Surface Area of Sphere is %f\n", area);

    return 0;
}

Output 1:
Enter Radius of the Sphere
2
Surface Area of Sphere is 50.240002

Output 2:
Enter Radius of the Sphere
10
Surface Area of Sphere is 1256.000000

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