error variables being used without initialization

yeah im completely new to c++
as in i started last week in school
so the function of the program I have written is to take a five digit integer and display each digit with three spaces between it.
for example, 54321 would come up as 5 4 3 2 1
however, the variables that have been assigned to each digit are coming up as uninitialized
i believe I have initialized them in the line int e, d, b, c, a;

// HW 2.28
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
int e, d, c, b, a;
int num = a + b*10 + c *100 + d *1000 + e * 10000;

cin >> num ;
cout << a <<" "<< b << " "<< c <<" "<< d <<" "<< e << endl;
}

Thank you very much for your help
Well, it seems you have several logical errors with your program.

You need to recognize that the program runs in sequential order. This means that when you initialize num on whatever line that is, it gets the value based on what a, b, etc are at that point, not later.

Second, C++ is not like math; the = sets whatever is on the left to be whatever is on the right in terms of values (not variables or equations).

Also, you are not intializing your variables. Initializing is like what you did with num. e, d, have no values assigned so they are garbage.

By the way, next time, use code tags to make your code easier to read:
http://cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.