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
The insertion sort algorithm sorts using what technique?
QveST [7]

Answer:

Iteration

Explanation:

The insertion sort is based on repetition of comparing one data array (or element in a list) with the others at its left to reorganize it, normally following a size criteria (from small to big or the other way around).

At each iteration, the algorithm takes one element and compares it one by one to the others until it fit the specified criteria. Later on, it creates a space, moving the other elements, to insert it. Later, it  goes to the next element and the iteration repeats all the way through. It has some advantages over other sorting algorithms because it is easy to deploy and program it in many different languages, but at the same time it can be terribly slow when sorting large amount of data.

7 0
2 years ago
in Google, how should you phrase your search if you want to exclude a certain word from your results(for example,"chocolate")?
dusya [7]
I found this:
ou can exclude words from your search by using the - operator; any word in your query preceded by the - sign is automatically excluded from the search results. Remember to always include a space before the - sign, and none after

I found it here:
http://www.informit.com/articles/article.aspx?p=675274&seqNum=3
3 0
2 years ago
Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Pie
I'd say PCIe x1... in terms of preformance
8 0
3 years ago
Read 2 more answers
Name two features that would be useful to potential customers
Dmitry [639]

Answer:

  1. How your business is unique
  2. A clear sense of what your company offers

Explanation:

Respond the subject "Who are you and What your business represents?" as interestingly and compellingly as feasible. This involves recording administration bios that state your expertise, times of struggle and various different qualities or details that may make you special from others.

"It's unbelievable how many businesses you visit and you're unsure something the organization offers". Execute it a superiority on your homepage to present at least comprehensive information regarding your outcomes and/or co-operation.

6 0
3 years ago
Plz answer all the questions :)
AURORKA [14]

Answer:

is there multiple choice or do i have to answer from my own words??

7 0
3 years ago
Other questions:
  • A network engineer is examining a configuration implemented by a new intern who attached an ip phone to a switch port and config
    9·1 answer
  • The sequence of folders to a file or folder is called a(n) ________
    8·1 answer
  • If your cousin wanted to view information from the world wide web, what application software would you tell her to be sure she h
    11·1 answer
  • What does the % find?
    9·2 answers
  • Write a program in C++ or C that includes two different enumeration types and has a significant number of operations using the e
    15·1 answer
  • Which of the following modes of replication requires a very low latency network connection and ensures data remains in synch wit
    9·1 answer
  • Provide instance fields for title, month, and year (for example, "Scientific American", "April", 2020). Each of these should be
    13·1 answer
  • How do i work on code with someone else? i use visual studio code. me and a friend wanna make a game together with code. how do
    8·1 answer
  • Any looping construct can be nested inside another loop is known as
    11·1 answer
  • Is there an air flow through the house? if so, does the air flow in the window and out the chimney, or in the chimney and out th
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!