140k views
2 votes
Write a C++ program to convert rainfall in inches to rainfallin millimeters given that:

1 inch = 25.4 mm
Sample output: 4 inches = 101.6 mm of rain

User Palto
by
5.9k points

1 Answer

5 votes

Answer:

#include <iostream>

using namespace std;

int main() {

float rainfall_inch,rainfall_mm;//declaring two variables of float type to hold the value rain in inches and mm.

cin>>rainfall_inch;//taking input of rain in inches..

rainfall_mm=rainfall_inch*25.4;//conveting inches to mm and storing in raingfall_mm.

cout<<rainfall_inch<<" inches = "<<rainfall_mm<<" mm of rain"<<endl;//printing the output.

return 0;

}

Step-by-step explanation:

The above written program is in c++ for converting the rainfall in inches to mm.

I have taken two variables of type float to store the values of rainfall in inches and mm.

Conversion of inches to mm.

Printing the result.

User Hanzo
by
6.1k points