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
Each generation is set apart from the previous generation because of an innovation.
ehidna [41]

Answer:

Second Generation: transistors

Third Generation: integrated circuits

First Generation: vacuum tubes

Explanation:

Generations of computers are categorized based on the technologies that were used in them.

Given innovations or technologies are:

<u>transistors :</u>

Transistors were introduced in the second generation in place of vacuum tubes.

<u>integrated circuits :</u>

Integrated circuits were introduced in the third generation. An IC consists of multiple transistors.

<u>vacuum tubes:</u>

The very first generation of computers used vacuum tubes to do the calculations. the only drawback was that the tubes used to heat up very soon.

Hence,

Second Generation: transistors

Third Generation: integrated circuits

First Generation: vacuum tubes

3 0
3 years ago
In critical thinking, an argument is:
djverab [1.8K]
C... it’s c ok.......................
6 0
3 years ago
Read 2 more answers
How do you invite someone to a conversation on brainly
Alona [7]
You can’t sorry dude
3 0
3 years ago
In c++ when you create a class and you don't want to put the class and the main program in one source file and let's say you cre
Alik [6]
Usually, you make a header file of the class with it's prototype and include it in your main program using double quotes instead of <>. This is how it's done with libraries that are compiled. In your case, this leaves the Class.cpp file unlinked. You could put an include at the end of the header file, or in this case I believe that you can just include the Class.cpp in your main source:

#include "Class.cpp"
8 0
3 years ago
Please design a Java GUI application with two JTextField for user to enter the first name and last name. Add two JButtons with a
Ede4ka [16]

Answer:

Check the explanation

Explanation:

Code :

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class nameFrame {

private JFrame mainFrame;

public nameFrame(){

prepareGUI();

}

public static void main(String[] args){

nameFrame nameFrame = new nameFrame();

}

private void prepareGUI(){

mainFrame = new JFrame("Name Frame");

mainFrame.setSize(450,250);

mainFrame.setLayout(new GridLayout(5, 2));

 

mainFrame.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent windowEvent){

System.exit(0);

}

});  

JLabel fname= new JLabel("First Name : ");

JLabel lname = new JLabel("Last Name : ");

JLabel fullname = new JLabel("Full Name : ");

JTextField fnameText = new JTextField(15);

JTextField lnameText = new JTextField(15);

JTextField fullnameText = new JTextField(30);

fullnameText.setEditable(false);

JButton submit = new JButton("submit");

submit.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {  

String data = fnameText.getText() + " " + lnameText.getText();

fullnameText.setText(data);

}

});

JButton clear = new JButton("clear");

clear.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {  

fnameText.setText("");

lnameText.setText("");

fullnameText.setText("");

}

});

mainFrame.add(fname);

mainFrame.add(fnameText);

mainFrame.add(lname);  

mainFrame.add(lnameText);

mainFrame.add(fullname);  

mainFrame.add(fullnameText);

mainFrame.add(submit);

mainFrame.add(clear);

mainFrame.setVisible(true);

}

}

Kindly check the attached output image below.

5 0
3 years ago
Other questions:
  • Which is not the option applicable to the technology reference framework for advanced countries?
    11·1 answer
  • In the case of a security incident response, the Building and Implementing a Successful Information Security Policy whitepaper c
    13·1 answer
  • Which of the following options allow you to access a computer remotely? Check all that apply.
    10·1 answer
  • In preparing his persuasive presentation, Reza should most likely focus on clearly presenting his
    6·2 answers
  • The Gauss-Seidel method as an iterative technique often refers to an improved version of the Jacobi method, since the Gauss-Seid
    13·1 answer
  • g Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative inte
    12·1 answer
  • Advantages of desktop publishing over traditional methods include       
    11·1 answer
  • What is meant by astigmation​
    9·2 answers
  • A column does not consist of
    10·1 answer
  • Write a pseudocode for the logic of a program that accepts five numbers from a user and displays one of the following messages:-
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!