| View previous topic :: View next topic |
| Author |
Message |
The Fish Expert Cheater
Reputation: 3
Joined: 11 Aug 2008 Posts: 114 Location: Ohio bitch
|
Posted: Wed Feb 23, 2011 11:10 am Post subject: need help setting up a variable in visual c++ |
|
|
| Code: | // Include the iostream library
#include <iostream>
//Use the standard namespace
using namespace std;
void ( )
{
<< cout << "Please pick a number between 1 and 10. Press any key to continue" << endl;
system ("PAUSE");
<< cout << "Insert your number below." << endl;
>> cin >> Number_1
float Number_1 << endl;
float Number_2 = NEED RANDOM NUMBER HERE << endl;
float Result =Number 2
} |
C'mon.
I need some help.
_________________
It was nice while it lasted. |
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Feb 23, 2011 11:19 am Post subject: |
|
|
random number from 1 to 10
it is in <stdlib.h>
|
|
| Back to top |
|
 |
The Fish Expert Cheater
Reputation: 3
Joined: 11 Aug 2008 Posts: 114 Location: Ohio bitch
|
Posted: Wed Feb 23, 2011 11:25 am Post subject: |
|
|
| Code: | // Include the iostream library
#include <iostream>
//Use the standard namespace
using namespace std;
void ( )
{
<< cout << "Please pick a number between 1 and 10. Press any key to continue" << endl;
system ("PAUSE");
<< cout << "Insert your number below." << endl;
>> cin >> Number_1
float Number_1 << endl;
float Number_2 = rand() % 10 + 1; << endl;
float Result =Number 2
system ("PAUSE");
} |
that's what I have now.
but where do I add the "<stdlib.h>"?
_________________
It was nice while it lasted. |
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Feb 23, 2011 11:43 am Post subject: |
|
|
| #include <stdlib.h>
|
|
| Back to top |
|
 |
The Fish Expert Cheater
Reputation: 3
Joined: 11 Aug 2008 Posts: 114 Location: Ohio bitch
|
Posted: Wed Feb 23, 2011 11:55 am Post subject: |
|
|
Now i need to know why this won't build.
| Code: | #include <iostream>
#include <stdlib.h>
//Use the standard namespace
using namespace std;
void ( )
{
<< cout << "Please pick a number between 1 and 10. Press any key to continue" << endl;
system ("PAUSE");
<< cout << "Insert your number below." << endl;
>> cin >> Number_1
float Number_1 << endl;
float Number_2 = rand() % 10 + 1; << endl;
float Result =Number 2
system ("PAUSE");
} |
_________________
It was nice while it lasted. |
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Feb 23, 2011 12:02 pm Post subject: |
|
|
| Code: | #include <iostream>
#include <stdlib.h>
//Use the standard namespace
using namespace std;
void ( )
{
float Number_1;
float Number_2 = rand() % 10 + 1;
float Result =Number 2;
cout << "Please pick a number between 1 and 10. Press any key to continue" << endl;
system ("PAUSE");
cout << "Insert your number below." << endl;
cin >> Number_1;
system ("PAUSE");
} |
no idea of what you are doing though.
|
|
| Back to top |
|
 |
The Fish Expert Cheater
Reputation: 3
Joined: 11 Aug 2008 Posts: 114 Location: Ohio bitch
|
Posted: Wed Feb 23, 2011 12:07 pm Post subject: |
|
|
| gogodr wrote: | | Code: | #include <iostream>
#include <stdlib.h>
//Use the standard namespace
using namespace std;
void ( )
{
float Number_1;
float Number_2 = rand() % 10 + 1;
float Result =Number 2;
cout << "Please pick a number between 1 and 10. Press any key to continue" << endl;
system ("PAUSE");
cout << "Insert your number below." << endl;
cin >> Number_1;
system ("PAUSE");
} |
no idea of what you are doing though. |
working on a number guesser.
You put a number in, and it give you a random number between 1 and 10.
It'll congratulate you if you're right once I'm done.
_________________
It was nice while it lasted. |
|
| Back to top |
|
 |
Aniblaze Grandmaster Cheater Supreme
Reputation: 138
Joined: 23 Apr 2006 Posts: 1757 Location: The Netherlands
|
Posted: Wed Feb 23, 2011 12:08 pm Post subject: |
|
|
| From what I can gather the following causes the failure in building: "void" should be "void main", and "Number 2" should be "Number_2".
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Feb 23, 2011 12:58 pm Post subject: |
|
|
| Augustine wrote: | | From what I can gather the following causes the failure in building: "void" should be "void main", and "Number 2" should be "Number_2". | this
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
Posted: Wed Feb 23, 2011 2:31 pm Post subject: |
|
|
void should be int main. here's a random function for you:
| Code: | int rand() {
return 4;
} |
|
|
| Back to top |
|
 |
gogodr I post too much
Reputation: 125
Joined: 19 Dec 2006 Posts: 2041
|
Posted: Wed Feb 23, 2011 2:50 pm Post subject: |
|
|
| Slugsnack wrote: | void should be int main. here's a random function for you:
| Code: | int rand() {
return 4;
} |
|
lol
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Feb 23, 2011 3:34 pm Post subject: |
|
|
| Slugsnack wrote: | void should be int main. here's a random function for you:
| Code: | int rand() {
return 4;
} |
|
Oh shit, lol'd.
PS. The comments in that code are so useful
|
|
| Back to top |
|
 |
Slugsnack Grandmaster Cheater Supreme
Reputation: 71
Joined: 24 Jan 2007 Posts: 1857
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Feb 23, 2011 6:56 pm Post subject: |
|
|
| Slugsnack wrote: | | http://xkcd.com/221/ |
that's why I found it amusing =]
|
|
| Back to top |
|
 |
|