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
Which of the following is the output of the code
olya-2409 [2.1K]

Answer:

need to see code

3 0
4 years ago
What type of dns servers field dns queries, send iterative queries to upstream dns servers, or send requests to forwarders and t
photoshop1234 [79]

Answer:

catching only server to send iterative queries to upstream DNS servers, or send requests to forwarders

<h3>what DNS server normally sends iterative questions with another DNS server?</h3>
  • The DNS server sends an iterative query to a root server.
  • The root server responds with a referral to the top-level domain server address. a. Client's DNS server, with the top-level domain server address, generates a new iterative query and sends it to the top-level domain server.

To learn more about DNS servers, refer

to brainly.com/question/2051280

#SPJ4

6 0
2 years ago
Which of the following statements comparing debit cards to credit cards is TRUE?
liq [111]
<span>The question has a few multiple choices one can choose from;

</span><span>A. Debit cards allow you to draw funds directly from your checking account. 
B. Debit cards typically offer greater fraud protection than credit cards.
C. Debit cards never require a signature to finalize a purchase like credit cards.
D. Debit cards charge higher interest rates on purchases than credit cards</span><span>

The Answer is (A) Debit cards allow you to draw funds directly from your checking account.

Checks were replaced by Debit cards as a way of paying for goods or drawing funds from your checking account. Since your debit card comes with your checking account, its simplicity will work nearly everywhere a credit card works. Adding a credit card to your checking account is just adding a layer of complications to your finances.
The fact that a debit card draws on money you already have, those who spend a lot would do well with debit cards and avoid the temptation of credit.</span>
3 0
3 years ago
Read 2 more answers
What would you need to install if you have an app that is incompatible with your current operating system?
Angelina_Jolie [31]

Answer:

D. A virtual machine

Explanation:

7 0
3 years ago
Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angl
KatRina [158]

Answer:

1. Modified formulae for calculating tree height.

treeHeight = tan(angleElevation)\times shadowLength.

2. C++ program to calculate tree height.

#include<iostream>

#include<math.h>

using namespace std;

int

main ()

{

 double treeHeight, shadowLenghth, angleElevation;

 cout << "Please enter angle of elevation and shadow length" << endl;

 cin >> angleElevation;

 cin >> shadowLenghth;

 

 //Modified formulae to calculate tree height.

 treeHeight = tan (angleElevation) * shadowLenghth;

 cout << "Height of tree is:" << treeHeight;

}

Output:

Please enter angle of elevation and shadow length

45

12

Height of tree is:19.4373

Explanation:

Since no programming language is mentioned, so solution is provided using C++.

In the above C++ program, first angle of elevation and length of shadow provided by user will be stored in variables angleElevation and shadowLength.

Then using  the modified formalue height of tree will be  calculated and stored in variable treeHeight. Final result is displayed to user.

6 0
3 years ago
Other questions:
  • Which of the following is true?
    6·1 answer
  • I need a free flashdrive can anyone tell me any website links so i can get one for free????​
    11·1 answer
  • Describe the Pros and Cons Associated with Cloud Computing Cloud Computing was introduced in 1999 by a company named "Salesforce
    12·1 answer
  • Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less
    6·2 answers
  • What are all the physical components called?
    6·1 answer
  • A string with delimiters can be parsed into separate fields using the _____ class.
    8·1 answer
  • How many pieces can be connected on to a to an SPS​
    11·1 answer
  • What is the number system that uses only the numbers 0 and 1?
    8·1 answer
  • Consider the following code.
    7·2 answers
  • Program Convert Measurements:
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!