'uninitialized local variable x'...? please help

Hi, I don't see how 'x' is uninitialized here, can someone explain please? (i'm only just learning)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
using namespace std;

void md (int x, int& multiply, int& divide)
	{multiply = x*2;
divide = x/2;
}

int main ()
{
	int x, y, z, a, n;
  string hello = "Hello";
	  cout << hello;
	  cout << "\nPlease enter what you'd like to countdown from";
		  cin >> a;
		  for (n=a; n>0; n--)
			{  cout << n << ", ";
			}
			cout << "please enter a value";
			md (x, y, z);
				cin >> x;
					cout << "double" << x << "is " << y << "half of" << x << "is " << z;
  return 0;
 
}
Last edited on
x is uninitialized on line 21 because you initialize it on line 22
Thanks :)
Topic archived. No new replies allowed.