How to solve the c++ problem using steps
Step 1: Declare a double variable named miles with initial value 100.
Step 2: Declare a double constant named KILOMETERS_PER_MILE with value
1.609.
Step 3: Declare a double variable named kilometers, multiply miles and
KILOMETERS_PER_MILE, and assign the result to kilometers.
Step 4: Display kilometers to the console.
What is kilometers after Step 4?
#Beginner
In gcc c++ compiler using namespace std;
#include<iostream>
using namespace std;
int main()
{
/*Step 1: Declare a double variable named miles with initial value 100 */
const double MILES = 100;
/*Step 2: Declare a double constant named KILOMETERS_PER_MILE with value 1.609. */
const double KILOMETERS_PER_MILE=1.609;
/* Step 3: Declare a double variable named kilometers, multiply miles and
KILOMETERS_PER_MILE, and assign the result to kilometers */
double kilometer = MILES * KILOMETERS_PER_MILE;
/* Step 4: Display kilometers to the console.
What is kilometers after Step 4? */
cout<<"kilometers is : "<<kilometer;
}
Output
kilometers is : 160.9
[Program finished]
Comments
Post a Comment
Any doubt about programming or questions