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
Hand tools are generally classified based on :​
makkiz [27]

Categories of hand tools include wrenches, pliers, cutters, files, striking tools, struck or hammered tools, screwdrivers, vises, clamps, snips, hacksaws, drills, and knives. Outdoor tools such as garden forks, pruning shears, and rakes are additional forms of hand tools. Portable power tools are not hand tools.

4 0
3 years ago
Mauricio plans on retiring in 20 years, and he wants to double his money by that time. He has contacted various banks, looking f
Novosadov [1.4K]

The rule of 72 is a very simple way to estimate and determine the number of years required to double your investments given a fixed annual rate of interest. It can also estimate and then calculate the annual interest rate required to double an investment in a given number of years. In the rule of 72, you can either choose to calculate the annual interest rate or the number of years.  

Use this formula to calculate the rule of 72

Rule of 72  ≈ 72 ÷ interest rate ≈ number of years to double

7 0
3 years ago
Which of the following can be considered classifications of technology companies? (Select all that apply)
artcher [175]
The answer is A, B, and C.

D. is too broad a term that actually includes A-C. So in other words there is no company that specializes in "Technology"

There are companies that specialize in E-Commerce, Hardware, and Security.

I guess if you wanted to say Google and Apple are technology companies you could say that but even they would fit into a particular classification. Google would be a Search Engine technology, and Apple would probably still be considered a hardware company even though both companies are involved across all of the 3 subjects in the answer.
4 0
4 years ago
Unscramble the words <br><br> A: ESUOM RETUPOC <br><br> B: KSID EVIRD
Mrrafil [7]
A. Mouse coputer
B. Disk drive
5 0
4 years ago
Read 2 more answers
Most common level of education for a programmer or software developer
shusha [124]

c/c+ also java would be one

8 0
3 years ago
Other questions:
  • _____ is when network managers deal with network breakdowns and immediate problems instead of performing tasks according to a we
    9·1 answer
  • One of the earliest uses of an electronic digital computer involved ________.
    8·1 answer
  • Micheal has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use? A
    15·1 answer
  • Match each scenario to the absolute value expression that describes it. 1. the distance moved when going backwards five spaces i
    13·2 answers
  • Universal containers regularly imports Accounts from an external order system that has its own ID field for each record.What sho
    8·1 answer
  • Many electronic devices use a(n) ?, which contains all the circuit parts in a miniature form.
    14·2 answers
  • Android OS "AFTER" Beta.<br><br> A. Cupcake<br><br> B. Candy<br><br> C. Cookie<br><br> D. Carmel
    12·1 answer
  • Which of the data repositories serves as a pool of raw data and stores large amounts of structured, semi-structured, and unstruc
    9·1 answer
  • You have imported a library with the birthMonth() function. Based on the API, how many strings are inputed to calculate the birt
    11·1 answer
  • Ways on how to conserve energy.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!