0
Instructions "John wrote a program that picks random numbers from 1 to 20. The program then ask users to guess the number it pic
9 Antworten
+ 6
EMMANUEL ANTWI DOKU ,
it is better for you to *start your own post*, otherwise poeple will not get aware of you. please also include your current code in the post..
also it is not clear if the task description from this thread is identical of what you want to know.
+ 5
EMMANUEL ANTWI DOKU ,
> please link your code try here
+ 2
Do you run the code?
Are you facing any trouble?
Are you getting the output you required?
Corrections depends on these your answers!!..
+ 1
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand(time(0)); // seed the random number generator with the current time
int number = rand() % 20 + 1; // generate a random number between 1 and 20
int guess;
do {
cout << "Guess a number between 1 and 20: ";
cin >> guess;
if (guess > number) {
cout << "Choose a lesser value." << endl;
} else if (guess < number) {
cout << "Choose a greater value." << endl;
} else {
cout << "Congratulations! You guessed the number." << endl;
}
} while (guess != number);
return 0;
}
+ 1
Alright
Thanks
0
Please this is my first time taking this I honestly have no idea where to begin
0
Any corrections to this code
0
I don't see anything wrong with it. It won't work in the code playground though. You are most likely going to need multiple inputs and the code playground here doesn't handle input within a loop well. Try compiling it yourself on your pc
0
Design Item class having ltem-Code, Name, Price, 20
and Stock in hand as data member. Add appropriate
member functions. Write a Java program that accepts
details of N Item and display items details in ascending
order of their stock.
Can anyone slove this in java