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
Debora [2.8K]
3 years ago
12

What is the output of the following program?

Computers and Technology
1 answer:
Natasha2012 [34]3 years ago
6 0

Answer:

Output of the program is following

sum=45

Explanation:

The execution of the program in the "for" loop  will be following

For k=0

=> val=1 and sum=0+1=1

For k=1

=> val=2 and sum=1+2=3

For k=2

=> val=3 and sum=3+3=6

For k=3

=> val=4 and sum=6+4=10

For k=4

=> val 5 and sum=10+5=15

For k=5

=> val=6 and sum=15+6=21

For k=6

=> val =7 and sum=21+7=28

For k=7

=> val=8 and sum=28+8=36

For k=8

val=9 and sum=36+9=45

So all the iterations of for loop are completed and the output is 45.

I hope it will help you!

You might be interested in
Internet is a boon or curse
tangare [24]
It really depends on what you're using it for such as looking up a recipe or an answer to a question. If you're using it for illegal purposes or looking up things that are seen as morally wrong by other people it can make the internet seem like a bad thing. But the internet wasn't created with that intended purpose so again it's just your own personal opinion.
4 0
3 years ago
How many times is the coin tossed?
valina [46]

Answer:

100 times.

Explanation:

The code will loop until i is equal to or greater than roles. I starts at zero and increases by one after each toss.

3 0
2 years ago
Read 2 more answers
Alcohol is considered a _____ drug
andreyandreev [35.5K]
Bad.......................
8 0
3 years ago
Read 2 more answers
Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi
ollegr [7]

Answer:

Here is the copy assignment operator for CarCounter:

CarCounter& CarCounter::operator=(const CarCounter& objToCopy) {

carCount = objToCopy.carCount;

return *this;  }

The syntax for copy assignment operator is:

ClassName& ClassName :: operator= ( ClassName& object_name)

In the above chunk of code class name Is CarCounter and object name is objToCopy.

Assignment operator = is called which assigns objToCopy.carCount to the new objects's carCount.

This operator basically is called when an object which is already initialized is assigned a new value from another current object.

Then return *this returns the reference to the calling object

Explanation:

The complete program is:

#include <iostream>  //to use input output functions

using namespace std;   //to access objects like cin cout

class CarCounter {  //class name

public:  // public member functions of class CarCounter

CarCounter();  //constructor of CarCounter

CarCounter& operator=(const CarCounter& objToCopy);  //copy assignment operator for CarCounter

void SetCarCount(const int setVal) {  //mutator method to set the car count value

carCount = setVal;  } //set carCount so setVal

int GetCarCount() const {  //accessor method to get carCount

return carCount;  }  

private:  //private data member of class

int carCount;  };    // private data field of CarCounter

CarCounter::CarCounter() {  //constructor

carCount = 0;  //intializes the value of carCount in constructor

return; }  

// FIXME write copy assignment operator  

CarCounter& CarCounter::operator=(const CarCounter& objToCopy){

/* copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *this */

carCount = objToCopy.carCount;

return *this;}  

int main() {  //start of main() function

CarCounter frontParkingLot;  // creates CarCounter object

CarCounter backParkingLot;   // creates CarCounter object

frontParkingLot.SetCarCount(12);  // calls SetCarCount method using object frontParkingLot to set the value of carCount to 12

backParkingLot = frontParkingLot;  //assigns value of frontParkingLot to backParkingLot

cout << "Cars counted: " << backParkingLot.GetCarCount();  //calls accessor GetCarCount method to get the value of carCount and display it in output

return 0;  }

The output of this program is:

Cars counted = 12

3 0
3 years ago
PLz answer I really need the answer
zlopas [31]

Answer:

a

Explanation:

job leads

4 0
3 years ago
Read 2 more answers
Other questions:
  • What type of computer would integrate the system unit with the display and keyboard?
    7·1 answer
  • Host A and B are directly connected with a 100 Mbps link. There is one TCP connection between the two hosts, and Host A is sendi
    14·1 answer
  • Which type of hypervisor does not run on an underlying operating system?
    13·1 answer
  • The Healthy Nutrition Counseling Center and the Simple Solutions Software Company have recently joined forces to produce a meal
    12·1 answer
  • The italic button is located on the
    6·1 answer
  • Write code which takes a user input of a String and an integer. The code should print each letter of the String the number of ti
    15·2 answers
  • ¿El auto es un servicio tecnológico? / The car is a technological service?
    11·1 answer
  • Which function works best when you need to remove an element at a specific index in a list?
    11·1 answer
  • In one to two sentences, describe how you would create a border around a group of cells.
    7·1 answer
  • Which of the following is not harmful to the computer?<br> a) Trojan<br> b) Rootkit<br> c)Malware
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!