Hello,
My name is MP and I am new to C++. I am trying to create a project and am having no luck.
I am trying to finish a assignment, but I am baffled. The assignment is to Write a program that reads in three integers and determines and prints the middle number numerically in the group. The values are NOT necessarily entered in numeric order. Also compound if statements and nested if statements are not needed or allowed).
Here is the code I wrote, but keep getting the 3 error C2059: syntax error : 'if'.
Code:
// Three integers printing middle interger numberically: 1/14/2008, 2:05PM
//
#include <iostream> // allows program to output data to the screen
#include "Rhod_2a.h"
using std::cout; // program uses cout
using std::cin; // program uses cin
using std::endl; // program uses endl
// function main begins program execution
int main()
{
int number1; // first integer to compare
int number2; // second integer to compare
int number3; // third integer to compare
cout << "Enter three integers: "; //prompt user for data
cin >> number1 >> number2 >> number3; // read three integers from user
if ( number1 <= number2 )
cout << number1 <<
if (number2 < number1 )
cout << number2 <<
if ( number3 < number1 )
cout << number3 << endl;
if ( number1 > number2 )
cout << number1 <<
if ( number2 > number1 )
cout << number 2 <<
if ( number2 < number3 )
cout << number2 <<
if ( number3 <= number2 )
cout << number3 << endl;
if ( number1 > number2 )
cout << number1 <<
if ( number1 > number3 )
cout << number1 <<
if ( number2 > number1 )
cout << number2 <<
if ( number2 > number3 )
cout << number2 <<
if ( number3 > number1 )
cout << number3 <<
if ( number3 > number2 )// number3 is greater than number2
cout << number3 << endl;
return 0; // indicate that program ended successfully
} //end function main
Errors:
------ Build started: Project: Rhod_2a, Configuration: Debug Win32 ------
Compiling...
Rhod_2a.cpp
c:\documents and settings\.your-jz14f3vb7a\my documents\visual studio 2005\projects\rhod_2a\rhod_2a\rhod_2a.h(33) : error C2059: syntax error : 'if'
c:\documents and settings\.your-jz14f3vb7a\my documents\visual studio 2005\projects\rhod_2a\rhod_2a\rhod_2a.h(42) : error C2059: syntax error : 'if'
c:\documents and settings\.your-jz14f3vb7a\my documents\visual studio 2005\projects\rhod_2a\rhod_2a\rhod_2a.h(54) : error C2059: syntax error : 'if'
Build log was saved at "file://c:\Documents and Settings\.YOUR-JZ14F3VB7A\My Documents\Visual Studio 2005\Projects\Rhod_2a\Rhod_2a\Debug\BuildLog.htm"
Rhod_2a - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========