October 25, 2022 |4.2K Views

    C Program to Convert Kilograms to Grams & vice versa

      Share   Like
    Description
    Discussion

    In this video, we will write a C Program Convert Kilograms to Grams & vice versa.

    Conversion of Kilograms to Grams:
    1 kg = 1000 g
    The mass m in grams( g) is equal to the mass m in kilograms( kg) times 1000 m( g) = m( kg) × 1000
    Example
    Convert2.5 kg to grams m( g) = 2. 5 kg × 1000 = 2450 g

    Convert Grams to Kilograms
    1 g = 1/1000 kg
    The mass m in kilograms( kg) is equal to the mass m in grams( g) time1/1000 m( kg) = m( g)/ 1000
    Example Convert 4783 g to kilograms m( kg) = 4783/ 1000 = 4.783 kg

    Algorithm to Convert Kilograms to Grams:
    Step 1: Take two variables.
    Step 2:  Take the value of the kilogram from the user and store it in the variable.
    Step 3: Multiply the kilogram value by 1000 and store the result in the output variable.
    Step 4: Print the value.

    Algorithm to Convert Grams to Kilograms:

    Step1: Take two variables for store value gram and kilogram.
    Step 2: Now take the value of the gram from the user and store it in the gram variable.
    Step 3: In this step divide the gram value by 1000 and store the result in the kilogram variable.
    Step 4: Print the value of the kilogram as output.