Finish the following program which adds up all integers fro

// Finish the following program which adds up all integers from 0 to the user\'s given number inclusively using a FOR loop. The total should be assigned to the variable \'total\'.

#include <iostream>

using namespace std;

int main()

{

int number;

int total;

cout << \"Enter a positive integer to find the summation of\"

<< \" all numbers from 0 to the given number.\" << endl;

cin >> number;

// TODO - Add your code here

cout << \"Total : \" << total << endl;

return 0;

}

for c++ Programming

Solution

Solution.cpp

#include <iostream>//header file for input output function

using namespace std;//std namespace

int main()

{//main function

int number;//variable declaration

int total=0;

cout << \"Enter a positive integer to find the summation of\"<< \" all numbers from 0 to the given number.    \";

cin >> number;

// TODO - Add your code here

for(int i=0;i<=number;i++)//for loop
total=total+i;
cout << \"Total : \" << total << endl;

return 0;

}

output

Enter a positive integer to find the summation of all numbers from 0 to the given number. 5

Total : 15

// Finish the following program which adds up all integers from 0 to the user\'s given number inclusively using a FOR loop. The total should be assigned to the
// Finish the following program which adds up all integers from 0 to the user\'s given number inclusively using a FOR loop. The total should be assigned to the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site