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
frosja888 [35]
3 years ago
7

Output a table that show the cube of the numbers 1-15 (C++)

Computers and Technology
1 answer:
Rainbow [258]3 years ago
3 0

Answer:

The c++ program to display cube of numbers from 1 to 15 is given below.

#include <iostream>

using namespace std;

int main() {    

   // variables declared and initialized  

   int num = 15, k, cube;    

   cout << " Cubes of numbers from 1 to 15 are shown below " << endl;    

   for( k = 1; k <= num; k++ )

   {

       // cube is calculated for each value of k and displayed

       cube = k * k * k ;

       cout << " \t " << cube << endl;

   }

return 0;

}

 

OUTPUT

Cubes of numbers from 1 to 15 are shown below  

  1

  8

  27

  64

  125

  216

  343

  512

  729

  1000

  1331

  1728

  2197

  2744

  3375

Explanation:

The variables are declared and initialized for loop, cube and for condition in the loop – k, cube, num respectively.

Inside for loop which executes over k, beginning from 1 to 15, cube of each value of k is calculated and displayed. The loop executes 15 times. Hence, cube for numbers from 1 to 15 is displayed after it is calculated.

   for( k = 1; k <= num; k++ )

   {

      cube = k * k * k ;

       cout << " \t " << cube << endl;

   }

In the first execution of the loop, k is initialized to 1 and variable cube contains cube of 1. Hence, 1 is displayed on the screen.

In the second execution, k is incremented by 1 and holds the value 2. The variable cube contains cube of 2, which is calculated, and 8 gets displayed on the screen.

After each execution of the loop, value of k is incremented.

After 15 executions, value of k is incremented by 1 and k holds the value 16. This new value is greater than num. Hence, the loop terminates.

You might be interested in
In three to five sentences, explain the function of the computer's operating system.
Sati [7]

Answer:

An Operating System (OS) is an interface between a computer user and computer hardware. An operating system is a software which performs all the basic tasks like file management, memory management, process management, handling input and output, and controlling peripheral devices such as disk drives and printers.

Explanation:

3 0
3 years ago
HELP ASAP PLZZZZZ
musickatia [10]

Answer:

third one

Explanation:

3 0
3 years ago
In ________- key encryption, two keys, known as a key pair, are created, where one key is used for coding and the other key for
Pavel [41]
In Encryption - ........
7 0
3 years ago
Which package is the Graphics class part of? _________________ .
Ksenya-84 [330]

Answer: C) java.awt

Explanation:

Java.awt is commonly used in AWT (abstract window toolkit) which basically contain core graphics in AWT class. The java.awt is the important package in the AWT. It basically contain the main capabilities of the graphics and define the GUI ( graphical user interface) frame in the java platform.

It also support the event handling and also the event class like window and key event in the java.awt.

Therefore, option (C) is correct.

8 0
3 years ago
If I gain a rank and go under the points that the rank coust do I lose the rank
padilas [110]
This is a good question, and I've wondered about that myself. I'm going to 'report' the question, not because there's anything wrong with it, but to bring it to the attention of the Moderators, so they can tell both of us.
4 0
3 years ago
Read 2 more answers
Other questions:
  • In 3–5 sentences, describe the unique challenges e-mail presents for business communications.
    13·2 answers
  • How do you interpret field in contest of a DBMS?
    5·1 answer
  • Which of the following refers to a technology with a three-dimensional computer simulation in which a person actively and physic
    11·1 answer
  • Each webpage is assigned a(n) ______, an address that identifies the location of the page on the Internet.
    6·1 answer
  • In windows, a(n) ________ follows the file name and a period and indicates the file type.
    9·1 answer
  • Each computer on a network requires a unique way to identify itself and to refer to other computers. This is accomplished by usi
    8·1 answer
  • Tech A says that gasoline vapors are lighter than air, so inspection pits do not have a fire hazard like above ground hoists. Te
    9·1 answer
  • Read the following scenario what type of business letter do you think is required in this situation?
    12·2 answers
  • What is keyboard? answer me <br>​
    12·2 answers
  • How to get the lightning round in dares of eternity
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!