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
What are 6 subtopics on computer programming ?
lubasha [3.4K]

On the internet, I found

Research topics

Artificial Intelligence

Computing and Mathematics

Cybersecurity

Data Science and Machine Learning

Embedded Systems and IoT

Process Management

Hope this helped :T

3 0
3 years ago
T F The exit function can only be called from main .
ElenaW [278]

Answer:

FALSE

Explanation:

The exit function is used to terminate or halt the process.

Syntax-

            void exit(int status)  

Exit function (exit()) can be used in any function not only main() and it will terminate your whole process.

<u></u>

<u>Example-</u> C Program

#include<stdio.h>

#include <stdlib.h>  

//  function declaration

float exitexample ( float x );                                

// Driver program

int main( )                

{

 float a, b ;

 printf ( "\nEnter some number for finding square \n");

  scanf ( "%f", &a ) ;

 // function call

 b = exitexample ( a ) ;                      

 printf ( "\nSquare of the given number %f is %f",a,b );  

/*This will not printed as exit function is in exitexample() function*/

}

float exitexample ( float x )   // function definition  

{

 exit(0);    //exit function

   float p ;

  p = x * x ;

return ( p ) ;

}

5 0
3 years ago
In a _error,solution is working but not giving required results
drek231 [11]

Answer:

<h2>it is a random error </h2>

Explanation:

<h3>I HOPE THAT THIS ANSWER HELPS YOU </h3>
7 0
2 years ago
The term load is often used to describe opening a page in a ____. Answer
mote1985 [20]
The answer is b web page
8 0
2 years ago
You have a Windows system that has both wired and wireless network connections. The wired connection is on the internal private
Oksana_A [137]

Answer: D. Enable the remote Assistance exception only on the private profile

Explanation:

4 0
2 years ago
Other questions:
  • Which change signaled a musical progression toward rock and roll?
    14·1 answer
  • 1. What is the difference between a learner’s license and an operator’s license?
    10·1 answer
  • A teacher uses the spreadsheet below to determine the average quiz score of each student. The teacher inserts this information i
    11·2 answers
  • If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement.
    6·1 answer
  • The True Confessions of Charlotte Doyle begins with what is called a(n) _____.
    15·1 answer
  • Which steps would you take to determine how much an employee should be paid? Select all that apply.
    9·1 answer
  • In 3 to 5 sentences, describe whether or not files should be deleted from your computer. Explain you answer.
    14·2 answers
  • Decrypt this message: P ht uva h zwf
    13·1 answer
  • Do you think it’s better for a young designer to use free, open-source art programs or to pay for commercial programs? Explain y
    14·1 answer
  • Jason is the motion picture projectionist at the local IMAX theater. This means that he runs the huge movie projector so that cu
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!