+ 2
It shows errors, what's the problem?
#include <iostream> using namespace std; int main() { int number; number>=15; int users number; cout<<"enter your number"<<endl;cin>>users number; if (number>users number){cout<<"you lose soos";} else{cout<<"you win!";} return 0; }
5 Antworten
+ 7
// Modifying your code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(time (0));
int number = 15 + rand() % 30;
int users_number;
cout<<"enter your number : ";
cin>>users_number;
if (number>users number)
cout<<"you lose soos";
else cout<<"you win!";
return 0;
}
+ 6
So you want number to be some random number which is greater than or equal to 15? E.g.
#include <cstdlib>
#include <ctime>
int main()
{
srand(time(0));
number = 15 + (rand() % 30);
}
This way, number would be a random number from a range of 15 to 44 (15+29).
+ 4
number >= 15; returns a boolean value to nowhere. (you probably mean number = 15; ?)
A variable name cannot contain whitespaces, i.e. "users number" should be "users_number".
Cout and cin statements should be separated.
cout << "something";
cin >> something.
+ 1
thank you. that's exactly what I wanted
0
thanks! modified it and it worked! but I wanted "number" to be more than or equal to 15