Hi, noob here with a quick question.... In the following code I'm trying to initialize int limit with a value using the if else statement. However when I try to compile, the compiler says that the limit variable is uninitialized. Can someone please tell me what I'm doing wrong and how to correct it? Thanks in advance....
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int cyear;
cout << "What is the current year?" << endl;
cin >> cyear;
if(cyear > 1980)
int limit = 10;
else
int limit = 5;
Hi Vlad, thanks for you quick response, but I tried what you suggested and I'm still getting the same error: int limit is being used without being initialized. I understand that the limit variable is local within the if and else statements, how can I get them to return their values to the main argument?