-2

Where Im mistaking. It says that number variable is not initialized.

#include <iostream>
using namespace std;
int ispisi_broj(int a) {

    cout << " Input number: ";
    cin >> a;
    cout << a;
    return 0;
}
int main() {
    int number; 
    ispisi_broj(number);
user4581301
  • 33,082
  • 7
  • 33
  • 54

1 Answers1

0

In this function

int ispisi_broj(int a) {

    cout << " Input number: ";
    cin >> a;
    cout << a;
    return 0;
}

the value of the parameter a is not used because it is at once reassigned in this statement

cin >> a;

So the function declaration does not make a great sense.

Also the return type int of the function also does not make a sense.

It seems you mean the following

#include <iostream>
using namespace std;

void ispisi_broj( int &a ) 
{
    cout << " Input number: ";
    cin >> a;
}

int main() 
{
    int number; 

    ispisi_broj(number);

    cout << " Input number: ";
    cout << a << '\n';
    return 0;
}

That is if you want to change the variable number declared in main within the function ispisi_broj then you need to pass it to the function by reference.

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335