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
Museum web sites are generally good resources for information.<br> A.) True<br> B.) False
Hatshy [7]
True. Museums usually specialize in one area in specifics.

Ex. WWII Museums give great historical info on WWII
8 0
3 years ago
Read 2 more answers
Isabel is creating a wireframe. She has drawn a layout for the home page along with outlining the navigation elements. She now w
Juli2301 [7.4K]

Answer: Filler content

Explanation: I think what the question is getting at is using filler content. This includes filler images and sample text. Once the website is all set up, the filler content is replaced with the actual content.

3 0
3 years ago
Read 2 more answers
"Bullet Lists" can be which of the following?
MariettaO [177]

Answer:

letters and numbered

Explanation:

7 0
3 years ago
Read 2 more answers
Create a stack with three integers and then use .toarray to copy it to an array.
Marizza181 [45]

Answer:

import java.util.*;

import java.lang.*;

import java.io.*;

class Codechef

{

public static void main (String[] args)

{

    Stack<Integer> mat=new Stack<Integer>();

    mat.add(1);

    mat.add(3);

    mat.add(6);

    System.out.println(mat);

    Object [] a=mat.toArray();

    for(int i=0;i<a.length;i++)

    System.out.println(a[i]);

}

}

Explanation:

An integer type stack st is created;

1,3 and 6 are added to the stack.

printing the contents of the stack.

array a is created form the stack using toArray().

Then printing the array.

6 0
3 years ago
Taking into account recent technological developments, what technical advances do you think are possible in the next twenty year
stiv31 [10]

Nuclear Fusion reactors may reach the prototype commercial stage , The causes and possible treatment of Alzheimers Disease  and Partial cloning of human organs for transplant therapy

Explanation:

Fusion may be an energy technology that seems to be perpetually coming over the horizon, but projects around the world such as SPARC are getting increasingly close to reactors that, although smaller in capacity, can produce net positive power in just a few years. To help accelerate discovery of permanent cure for Alzheimers, an alliance of pharmaceutical companies, nonprofit foundations and government advisers, has developed a partnership to share data from Alzheimer's clinical trials. This would definitely pave way for the permanent cure for Alzheimer. The most common method of therapeutic and reproductive cloning is somatic cell nuclear transfer (SCNT). SCNT involves separating the nucleus from a donor egg, and replacing it with the DNA from the organism meant to be cloned. Scientists could potentially clone organs with SCNT by cloning embryos, extracting the stem cells from the blastocyst, and stimulating the stem cells to differentiate into the desired organ. these three scientific and technological advancements are possible.

8 0
3 years ago
Other questions:
  • A peripheral can be used to tell a computer to complete a specific task. True False
    15·1 answer
  • Define the method object inc_num_kids() for personinfo. inc_num_kids increments the member data num_kids. sample output for the
    11·1 answer
  • SecOps focuses on integrating the need for the development team to provide iterative and rapid improvements to system functional
    11·1 answer
  • A function may return a pointer, but the programmer must ensure that the pointer:
    14·1 answer
  • Which CSS attribute would change an element's font color to blue
    15·2 answers
  • According to company policy and administrator must logically keep the Human Resources department separated from the Accounting d
    5·1 answer
  • the outline view allows you to control how much information you can see in a document, because you can expand or collapse sectio
    12·1 answer
  • Ill give alot of points if you answer: How do I get a 100 dollar ps4
    5·2 answers
  • A search for reliable information is a search for what?
    14·1 answer
  • Which protocol is often used in conjunction with ipsec to provide a remote access client vpn with user authentication?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!