C++ program to convert kilograms to grams

Views: 6   

Following program shows you how to convert kilograms to grams.
In this program we get kilograms from user, once we get those we need to multiply with 1000 so that we get in grams

#include <iostream>
#include <math.h>

int main() {
    float kilograms;
    std::cout << "Please enter kilograms:";
    std::cin >> kilograms;
    float grams = kilograms * 1000;
    std::cout << grams << " Grams";
}

Output:

Please enter kilograms: 5
5000 Grams
On By