• Announcements

Archived

This topic is now archived and is closed to further replies.

Visual C++ help!

Recommended Posts

ericsondraal    122
i am 13 and i am very new at c++ i have been using it for a few hours... i tryed to right a program but i got 1 error Could you PLZ!!!! HELP ME!! #include <iostream> #include <stdlib.h> using namespace std; { float x = 0; float y =0; int Number = 0; cout << "Enter 2 Numbers:" << endl; cin >> x >> y; cout << "What do you want to do with them?" << endl << "(1) Add (2) Subtract (3) Multibly (4) Divide (5) Cout" << endl; cin >> Number; if(Number == 1) { cout << endl << x + t < y)) { for( ; x > y ; --x) { cout << x << endl; } return 0; } return 0; }

Share on other sites
red_sodium    216
You might get more responses if you told us the error...

Share on other sites
ericsondraal    122
sorry the error is

error C2447: missing function header (old-style formal list?)

Share on other sites
red_sodium    216
if(Number == 1){cout << endl<< x + t< return 0;}

Where it says "< return 0;" is your problem. Looks like you deleted a bit of code by accident. It should read:

if(Number == 1){cout << endl<< x + t<< endl;return 0;}

Share on other sites
nonpop    122
You should tell the exact error, too. (I see you already did )
However, I noticed your code has no main function. After using namespace std; instead of just a '{' there should be int main () { .
To keep the code formatted correctly, use the code -tag:

[ code ]
[ /code ]

(remove the the spaces from the tags)

To get the nice highlighting code box, use the source -tag

[edited by - nonpop on March 27, 2004 4:41:09 PM]

[edited by - nonpop on March 27, 2004 4:43:10 PM]

Share on other sites
ericsondraal    122
thank you for all the help!

Share on other sites
Spudder    385
You don''t seem to have a main() method which is mandatory for all C++ applications (Win32 apps use a variant called WinMain()), underneath using namespace std; add this line after it but before the opening curly brace: int main(int argc, char **argv) this should solve the error.

Share on other sites
ericsondraal    122
here it is it done
thanks for all the help!

#include <iostream>

using namespace std;
int main()
{
float x = 0;
float y =0;
int Number = 0;

cout << "Enter 2 Numbers:"
<< endl;

cin >> x >> y;

cout << "What do you want to do with them?"
<< endl
<< "(1) Add (2) Subtract (3) Multibly (4) Divide (5) Count"
<< endl;

cin >> Number;

if(Number == 1)
{
cout << endl
<< x + y
< return 0;
}
if(Number == 2)
{
cout << endl
<< x - y
<< endl;
return 0;
}
if(Number == 3)
{
cout << endl
<< x * y
<< endl;
return 0;
}
if(Number == 4)
{
cout << endl
<< x / y
<< endl;
return 0;
}
if((Number == 5) && (x <= y))
{
for( ; x < y ; ++x)
{
cout << x << endl;
}
cout << x << endl;
return 0;
}
if((Number == 5) && (x >= y))
{

for( ; x > y ; --x)
{
cout << x << endl;
}
cout << x << endl;
return 0;
}
return 0;
}