A simple 'else' without a previous 'if'
Hi all hope everyone is well :) I just started to learn c++ so I'm sorry this has been asked a million times before and I've been through half of google but it seems I'm too stupid to work this out! Can someone tell me where I'm going wrong?
Code:
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
{
int nAge;
cout << "Enter Age:";
cin >> nAge;
{
if (nAge < 0)
cout << "Age can't be negative; using 0." << endl;
nAge = 0;
}
else
{
cout << "Age of " << nAge << " entered" << endl;
}
}
return 0;
}