Answer to Question #47698 in C++ for laraib

Question #47698
write a program to convert kilogram into grams by passing pointer as argument to the function
1
Expert's answer
2014-10-10T02:01:25-0400
#include <iostream>
using namespace std;
double convert(double* kilograms);
//main method
int main()
{
double kilograms;
//promt user to enter kilograms
cout<<"Enter kilograms: ";
cin>>kilograms;
//show result
cout<<kilograms<<" kilogram(s) = "<<convert(&kilograms)<<" gram(s).\n";
system("pause");
//exit program
return 0;
}
//function convert to convert kilogram to gram by passing pointer as argument to the function
double convert(double* kilograms){
return *kilograms*1000;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS