My Simple Program Can't Add 2+2???

This one in mind boggling, I started with a much more complex program that was solving systems of non-linear equations and kept simplifying my code because I noticed it wasn't coming up with the right answer. I've simplified it until I have the following and found out... my program can't even add two numbers together! No wonder my equation solver wasn't working. No matter the numbers it just keeps outputting the extremely large number 1974705532. I just can't seem to figure out why and what's going on here.


This is the end code (doesn't get any simpler that this, folks):
#include <iostream.h>
int main() {

int a,b,c;
c = a+b;
cin >> a >> b;
cout << "c is " << c;
system("PAUSE");
return 0;
}


I'm hoping maybe someone has experienced some similarly odd behavior before because I'm at a loss here.

It may have happened to you programming on a Dev-C++ 4.9.9.2 build on a Windows 7 64-bit computer perhaps?
You are doing c = a + b before a and b have any real values so c is getting some random junk value
You are spreading the peanut butter before getting out the bread.

You have to ask for and obtain values for a and b before you can add them.

Hope this helps.
closed account (S6k9GNh0)
I love that analogy.
That was it, guys. Thanks so much. I will never forget my bread again. Trust me
Topic archived. No new replies allowed.