vendredi 12 mars 2021

c++ trying to change local variable outside of function?

I was given the following program:

#include <iostream>
using namespace std;

// ### write myFunction() ###

// ###

int main(){
    int x;
    cin >> x;
    myFunction(x);
    cout << "The Number + 1 is " << x;
}

I know I'm supposed to change x to x++, but how do I do so in myFunction() when x is a local variable in main()?

Aucun commentaire:

Enregistrer un commentaire