Question #208911

  • Write a program that declares an integer in main() functions. One function inputs a value in the variable defined in the main() function. The second function doubles the value of that variable

Expert's answer

#include <iostream>
using namespace std;
void input(int &x){
    cout<<"Input the value of the variable: ";
    cin>>x;
}
void doubles(int &x){
    x *= x;
}
int main(){
    int x;
    input(x);
    cout<<"Value of x: "<<x<<endl;
    doubles(x);
    cout<<"Value of x: "<<x<<endl;
    return 0;
}

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!

LATEST TUTORIALS
APPROVED BY CLIENTS