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
__________ has remained a dominant communication tool, despite the rise in use of newer, alternative media options for message d
maksim [4K]

Answer: E-mails

Explanation:

 An E-mails is one of the type of digital message and also known as the dominant communication tool which is used for in the form of document in an organization where we can used it in different ways are as follows:

  • Communicating with other employees related to rules and regulations of an organization
  • Making various types of recommendations
  • Used for an inquiry purpose
  • providing various types of current status and new updates

According to the given question, Emails is one of the type of tool that is used as the communication medium and it is one of the flexible message delivery options which is widely used by an organizations.

 

6 0
3 years ago
QUESTION 7
marishachu [46]
False, it needs to be properly cited because that is plagiarism which is illegal
6 0
3 years ago
The enter/return key is struck by the
Black_prince [1.1K]

Answer:

B

Explanation:

8 0
3 years ago
Read 2 more answers
The position at which a column and a row intersect is called a __________.
s344n2d4d5 [400]
A grid line which is A
8 0
3 years ago
In your Ice Breakers game, when does the player lose a life?
Ivanshal [37]

Answer:

D. When the snowball leaves the play area on the bottom

5 0
3 years ago
Read 2 more answers
Other questions:
  • What is an input, output and storage device?
    12·1 answer
  • Do you think that people have a “right” to remain anonymous online? Why or why not?
    6·1 answer
  • _____ is a predefined format used for text the can include multiple font formatting features
    13·1 answer
  • A technician has just installed a video card in a PC. The video card is not working, althoughit was working fine on the test ben
    6·1 answer
  • Net neutrality refers to the idea that Internet service providers (ISPs), including cable Internet and wireless carriers, should
    9·2 answers
  • .In Python, comments begin with the comment marker and continue ______.
    14·1 answer
  • Which of these trade-offs occur in a memory hierarchy?
    15·1 answer
  • Black and white squares codehs, i need the whole code (40 points for correct answer)
    15·2 answers
  • Write an algorithm to display your name 10 times​
    5·1 answer
  • Why would you use a computer's secondary memory?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!