Im learning c++ and im having problems with functions!
The line marked with // THIS LINE IS PROBLEM! has the following errors (please help me fix) :
Code:
1>d:\users\ant1jr\documents\visual studio 2005\projects\test 1\test 1\test 1.cpp(18) : error C2144: syntax error : 'int' should be preceded by ')'
1>d:\users\ant1jr\documents\visual studio 2005\projects\test 1\test 1\test 1.cpp(18) : error C2660: 'favnumber' : function does not take 0 arguments
1>d:\users\ant1jr\documents\visual studio 2005\projects\test 1\test 1\test 1.cpp(18) : error C2059: syntax error : ')'
Code:
#include <iostream>
#include <cstdlib>
using namespace std;
int favnumber(int number);
int main()
{
int input;
cout<<"Welcome to Ant1jr's Test Software!\n";
cout<<"1. Favorite Number \n";
cout<<"Input: ";
cin>> input;
switch ( input ) {
case 1:
favnumber( int number ); // THIS LINE IS PROBLEM!
break;
}
}
int favnumber(int number)
{
//The computer asks your fav number
cout<<"Hello, what's your favorite number? \n";
//You input your fav number
cin>> number;
cin.ignore();
//The computer responds with "Your favorite number is <number>!"
cout<<"Your favorite number is "<< number <<"! \n";
cin.get();
// If your favorite number is 2 you are identified as grandma.
if ( number == 2 ) {
cout<<"Hello Grandma! \n";
// Press enter and you are told "Bye Grandma!"
cin.get();
cout<<"Bye Grandma!";
}
else if ( number == 1337 ) {
cout<<"Hello Dad! \n";
// Press enter and you are told "Bye Dad!"
cin.get();
cout<<"Bye Dad!";
}
else if ( number == 42 ) {
cout<<"Hello Milo! \n";
// Press enter and you are told "Bye Milo!"
cin.get();
cout<<"Bye Milo!";
}
// If you input 666 it will contantly print "UNHOLY DEMON!" until you close the application.
else if ( number == 666 ) {
for ( int x = 0; x >= 0; x++ ) {
cout<<"UNHOLY DEMON! ";
}
}
// If you dont input 2, 1337, 42, or 666 you are told your number is low if <50 or high if >50"
else {
if ( number <= 50 ) {
cout<<"You have a low favorite number! \n";
// Press enter and you are told "Bye!"
cin.get();
cout<<"Bye!";
}
else {
cout<<"You have a high favorite number! \n";
cin.get();
// Press enter and you are told "Bye!"
cout<<"Bye!";
}
}
//Press enter to close.
cin.get();
}