1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Natasha_Volkova [10]
3 years ago
5

Write a short program that allows the user to input a positive integer and then

Computers and Technology
1 answer:
pogonyaev3 years ago
5 0

Answer:

// code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int n;

   cout<<"Enter a positive number:";

   // read number

   cin>>n;

   // check number is positive or not

   while(n<0)

   {

   // if number is negative

       cout<<"Wrong input!!"<<endl;

       // ask again to enter again

       cout<<"Enter again:";

       // read number again

       cin>>n;

   }

   // generate random number between 1 to n

   int ran=rand()%n +1;

   // print random number

   cout<<"Random number between 1 to "<<n<<" is: "<<ran<<endl;

return 0;

}

Explanation:

Read a number from user.Then if input number is negative then ask user to enter a positive number again.After this generate a random number between 1 to n.Print that random number.

Output:

Enter a positive number:-12

Wrong input!!

Enter again:9

Random number between 1 to 9 is: 2

You might be interested in
Three reasons why users attach speakers to their computer
Alla [95]
For media sound
For the game's multimedia sound
For essential system sound
5 0
3 years ago
Can you answer this ?​
beks73 [17]

Answer:

Answer it yourself.

Explanation:

NO.

4 0
3 years ago
Read 2 more answers
Rose has a list of two columns of information separated by tabs. She wants to input this information into a table. What is the f
andreev551 [17]
I gotchu my bro!!
it would be D. " clicking Convert Text to Table"
7 0
3 years ago
Read 2 more answers
HELP MEEE PLEASE!!!
Vladimir [108]

Answer:

b goes with 1 c goes with 3 and a goes with 2

Explanation:

3 0
3 years ago
How is energy expended in active transport​
professor190 [17]

Here's the biology explanation:

Most of the energy expended by a cell in active transport is used to pump ions out of the cell across the plasma membrane.

7 0
4 years ago
Other questions:
  • Microsoft windows is the least used operating system true or false?
    15·2 answers
  • Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prin
    8·1 answer
  • Do you like Houseparty?
    7·1 answer
  • Where can you access the property sheet
    8·1 answer
  • Providing incentives for customers to learn more about your service is known as?
    7·1 answer
  • Charlie makes pizza at a restaurant. The customers always compliment how great the pizza tastes. But Charlie takes a long time t
    7·2 answers
  • . Write a C++ Code to get a multiline statement Str1 from a user with a ‘$’ as return character (Hint:
    6·1 answer
  • Create five circles like the Olympic Rings. fill them with the colors given below
    8·1 answer
  • Which of the following is an example of effective nonverbal communication?
    8·1 answer
  • Does every loop structure require curly braces?<br> A. yes<br> B. no
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!