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
NAT is able to stop ________. Group of answer choices a) scanning probes sniffers from learning anything about the internal IP a
Nikitich [7]

Answer:

The answer to this question is option "b".

Explanation:

NAT stands for Network Address Translation. It translates the IP addresses of computers in a local network to a single IP address. NAT is responsible for stopping both scanning probes and sniffers from learning anything about the internal IP address and its hosting. Sniffing is a process of monitoring and catching all data packets moving within a distributed network. It uses the network or system administrator to control and troubleshoot fiber traffic. Scanning probes stands for Scanning Probes Microscopes (SPMs) used to create images of nanoscale covers the structures, including atoms. In this scanning method, a computer collects data that are used to create an image of the surface.

8 0
4 years ago
Read 2 more answers
9. These particular machines can be decentralized.
shusha [124]

Answer:

A, B

Explanation:

Because the desktop computer and the printers are decentralized, they're connected with another noce in a company.. So I suppose that the Risograph and photocopier isn't decentralized.

4 0
3 years ago
12. How many different documents can<br> you have open at one time?
uranmaximum [27]

Answer:

10 documents ^_^

Explanation:

I can open it at the same time on my laptop ●~●

3 0
4 years ago
Can someone help me find all the solutions to the problem ​
zepelin [54]
Answer this with the dots connected. Why is it. You may ask? I bet it’s 40
7 0
4 years ago
Read 2 more answers
What is the limitation of computer<br>​
eimsori [14]

The limitation of computer are:

  1. No self-intelligence
  2. No feeling
  3. No learning power
  4. Dependency

3 0
3 years ago
Other questions:
  • What common objects you think will benefit from embedded computers?
    15·1 answer
  • ​A(n) ________ database makes it possible to store information across millions of machines in hundreds of data centers around th
    6·1 answer
  • What is the Java source filename extension? What is the Java bytecode filename extension?
    14·1 answer
  • What are the advantages to using a linked implementation as opposed to an array implementation?
    8·1 answer
  • What does the CYMK tab let you do?
    5·2 answers
  • Hey guys I have a quick question about computer science I WILL MARK BRAINLIEST (crown )
    6·2 answers
  • Visme,PowerPoint, keynote and prezi are what kind of software
    15·1 answer
  • Write short notes about monitor printer and speaker​
    14·2 answers
  • What are the similarities characteristics between computer and human beings?​
    13·2 answers
  • What the three factors that AI is using for information gathering
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!