0

Hey all. I'm a beginner. Please somebody tell me what's wrong with the simple use of my else statement. The compiler says: "Error. Expected a statement."

// IfDemo.cpp : Defines the entry point for the console application.
//
// demonstration of IF statement

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{

// first argument
	int nArg1;
	cout << "Enter arg1: ";
	cin >> nArg1;

// second argument
	int nArg2;
	cout << "Enter arg2 ";
	cin >> nArg2;

// now decide what to do
	if (nArg1 > nArg2);
		{
		cout << "Heck yeah arg1 is larger! \n\n";
		}
	else
		{
		cout << "Afraid not, my friend. Sorry! \n\n";
		}
	
		
	return 0;
}

Edited by EdAtTheAirport: Add code tags.

5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by EdAtTheAirport
0

yeah your problem is you have a ; after your if statment at line 24. apart from that it should work

0

The semi-colon after the if statement should be removed. May I add that for such a simple program you complicated it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.