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
vodomira [7]
3 years ago
9

Write a complete C++ program that do following. Read a positive integer from the user with proper prompt. Assume that this user

is nice and he/she would not start the integer with digit 0. Create a size 10 array as counters for digits 0 - 9 Use a while loop for processing

Computers and Technology
1 answer:
exis [7]3 years ago
5 0

Answer:

The cpp program for the given scenario is shown below.

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

//variable for while loop

   int n=0;

   //size of array declared

   int size=10;

   //integer array declared

   int num[size];

   //user enters elements for the array inside while loop

   while(n<size)

   {

       std::cout << "Enter a positive number: ";

       cin>>num[n];

n++;

   }

   std::cout << "Thanks for entering the numbers. Program ends." << std::endl;

   return 0;

}

Explanation:

1. The integer variable, size, is declared and initialized to hold the size of the array.

int size=10;

2. Another integer variable, n, is declared to be used in the while loop.

int n=0;

3. An integer array, num, is declared having the capacity of integer variable, size.

int num[size];

4. Inside the while loop, the user is prompted to enter a positive number.

std::cout << "Enter a positive number: ";

5. The user-entered number is assigned directly to the array.

cin>>num[n]

6. After input is taken, the variable n is incremented by 1.

n++;

7. The while loop executes over variable n for the range of values from 0 to size-1,  i.e., until the array is filled. The first index of the array is 0 and increments henceforth. The variable is declared outside the loop unlike the for loop.

while(n<size)

8. In this program, all the code is written inside main().

9. Since cpp is not a purely object-oriented language, it is not mandatory to write the code inside the class for a simple program like this.

10. The program ends with a message for the user.

std::cout << "Thanks for entering the numbers. Program ends." << std::endl;

11. The return statement indicates the end of main() method.

return 0;

12. The output of the program is attached as an image.

13. The program can be tested for any value of variable size.

You might be interested in
A motorist is using the AHP to choose a new car from three possible models Arrow, a Bestmobile and a Commuter. The choice will a
Lynna [10]

Answer: i think the answer is A. Construct a hierarchy to represent the decision problem.

8 0
3 years ago
Read 2 more answers
What is computer Network?​
spayn [35]

Answer:

\boxed{\sf {view \: explanation}}

Explanation:

A computer network is a network of computers that can share data among the computers.

7 0
3 years ago
What option would fit the most content on a page?
zvonat [6]

Answer:

normal margins will fit the most content on a page

7 0
2 years ago
Bargain Bob's auto dealership sells vehicles. He sells Chrysler, Jeep, and Dodge brand vehicles. He tracks customer and manufact
marusya05 [52]

Answer:

Customer(1) - (1) Vehicle.

Explanation:

Cardinality is the mapping of entities or group of entities to a cardinal value. It tries to show the relationship between two objects like a cups in a shelf or plates in racks.

The car dealer in the question, sells one car to a customer and keep or prioritise the record of the main owner of the acquired vehicle. So the maximum cardinality assignment of the customer and vehicle is one (1) to one (1) mapping.

6 0
3 years ago
Which operating system became obsolete with the arrival of a more advanced graphical user interfaces
12345 [234]
The answer is Ms Dos
6 0
3 years ago
Other questions:
  • Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respect
    8·1 answer
  • In the lan protocol architecture the _________ layer is responsible for detecting errors and discarding any frames that are in e
    13·1 answer
  • A Windows application which demands a lot of raw processing power to execute repetitive complex calculations is a good candidate
    9·1 answer
  • Software enables users to create documents
    13·1 answer
  • Such a class might store information about the account balance, the name of the account holder, and an account number. What inst
    13·1 answer
  • Can you guys help me with this coding assignments?
    10·1 answer
  • Analog computers are general purpose computers : true ? or false ?​
    8·1 answer
  • Game Design!
    10·2 answers
  • What is the descriptor for a filter that warns or blocks you from potentially fraudulent or suspicious websites?.
    5·1 answer
  • ____must cooperate with each other to neutralize the global threat of information censorship. Select 3 options.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!