2 week in programming

I am learning to program in C++. I started off with 26 error, and now I am down to 1. I just dont understand what it is asking for in the errors. Can somebody help me out? I have tried to look on the internet but I still not understading the problem

//This program is going to take 2 numbers and tell which one is Smaller or equal and display it on the screen


#include <iostream>
using namespace std;

int main()
{


    // Step 1: Input number
    double number1;
    cout << "Input number: ";
    cin >> number1;

    // Step 2: Input number2
    double number2;
    cout << "Input number2: ";
    cin >> number2;

    // Step 3: Compute Numbers
    if (number1 < number2)
    cout << number1 <<

    else if ( number1 > number2)
    cout << number2 << 

    else (number1 = Number2)
     cout << it is equal << endl;

return 0;
}

1>------ Build started: Project: LAB2A, Configuration: Debug Win32 ------
1>Compiling...
1>LAB2A.cpp
1>y:\d02828527\documents\visual studio 2008\projects\lab2a\lab2a\lab2a.cpp(26) : error C2059: syntax error : 'else'
1>Build log was saved at "file://\\ilabss\home$\D02828527\Documents\Visual Studio 2008\Projects\LAB2A\LAB2A\Debug\BuildLog.htm"
1>LAB2A - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Edited 3 Years Ago by mike_2000_17: Fixed formatting

In an if...else logic test an else cannot take values to test against. The "else" is the catch-all. So, you should remove the condition you're testing for within your else.

You have many, many errors in this code:

#include <iostream>
using namespace std;

int main()
{

	// Step 1: Input number
	double number1;
	cout << "Input number: ";
	cin >> number1;

	// Step 2: Input number2
	double number2;
	cout << "Input number2: ";
	cin >> number2;

	// Step 3: Compute Numbers
	if (number1 < number2)
		cout << number1; //you forget about ;

	else if ( number1 > number2)
		cout << number2; //you forget about ;

	else if(number1 == number2) //you didn't declare Number2 and used = instead of ==
		cout << "it is equal" << endl; //"it is equal" should be in "..."

return 0;
}

Edited 6 Years Ago by Dakurels: Error

You have many, many errors in this code:

#include <iostream>
using namespace std;

int main()
{

	// Step 1: Input number
	double number1;
	cout << "Input number: ";
	cin >> number1;

	// Step 2: Input number2
	double number2;
	cout << "Input number2: ";
	cin >> number2;

	// Step 3: Compute Numbers
	if (number1 < number2)
		cout << number1; //you forget about ;

	else if ( number1 > number2)
		cout << number2; //you forget about ;

	else if(number1 == number2) //you didn't declare Number2 and used = instead of ==
		cout << "it is equal" << endl; //"it is equal" should be in "..."

return 0;
}

Ok I understand about the Equal sign I caught that after I posted my question on here but what am I doing wrong with the Number 2 not being declared I thought I did the same thing with Number 1 and Number2

You declared number2, no Number2.

Thanks, I over look that so many times.

cout << number1 <<

There is syntax errror in line. Every C/C++ Statement must end with semi-colon.
Check this and all other statements below this line.

This article has been dead for over six months. Start a new discussion instead.