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

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

Note: 1 Kilogram is approximately equal to 2.20462 Pound.

kilogram to pound

Formula To Convert Weight From Kilograms to Pounds

pound = kilogram * 2.20462;

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

Logic To Convert Kilograms to Pounds

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

Video Tutorial: C Program To Convert Kilograms to Pounds


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

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

Source Code: C Program To Convert Kilograms to Pounds

#include<stdio.h>

int main()
{
    const float POUND = 2.20462;
    float kg;

    printf("Enter weight in Kilograms\n");
    scanf("%f", &kg);

    printf("Weight in Pounds is %f\n", (kg * POUND));

    return 0;
}

Output 1:
Enter weight in Kilograms
5
Weight in Pounds is 11.023099

Output 2:
Enter weight in Kilograms
14
Weight in Pounds is 30.864678

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 Percentage Difference Between 2 Numbers

Given two numbers, write a C program to calculate percentage difference between those two numbers.

Formula To Calculate Percentage Difference Between Two Numbers

If user entered numbers are stored in variables a and b. Then the formula to calculate the percentage difference between a and b is:

result = ( |a-b| / ((a+b) / 2.0) ) * 100;

OR

result = ( abs(a-b) / ((a+b) / 2.0) ) * 100;

Note: abs() is a builtin method present in stdlib.h header file, which returns the absolute value.

Related Read:
Basic Arithmetic Operations In C

Check this video tutorial to know more about absolute value:
C Program To Find Absolute Value of a Number

Logic To Calculate Percentage Difference Between 2 Numbers

The percentage difference between two numbers is calculated by dividing the absolute value of the difference between two numbers by the average of those two numbers. And then multiplying the result by 100.

Expected Output for the Input

User Input:
Enter 2 numbers
100
200

Output:
Percentage difference is 66.666664

Video Tutorial: C Program To Calculate Percentage Difference Between 2 Numbers


[youtube https://www.youtube.com/watch?v=L7Vc7-1z9os]

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

Source Code: C Program To Calculate Percentage Difference Between 2 Numbers

#include<stdio.h>
#include<stdlib.h>

int main()
{
    float a, b, result;

    printf("Enter 2 numbers\n");
    scanf("%f%f", &a, &b);

    result = ( abs(a-b) / ( (a+b)/2.0 ) ) * 100;

    printf("Percentage difference is %f\n", result);

    return 0;
}

Output 1:
Enter 2 numbers
50
60
Percentage difference is 18.181818

Output 2:
Enter 2 numbers
60
50
Percentage difference is 18.181818

Output 3:
Enter 2 numbers
75
75
Percentage difference is 0.000000

Output 4:
Enter 2 numbers
75
100
Percentage difference is 28.571428

Output 5:
Enter 2 numbers
150
200
Percentage difference is 28.571428

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