Question #100802

Write a program that will display all numbers multiple of 7 which are between 1 and 100 and display the cumulative sum as well as the final sum.

Expert's answer

#include <iostream>

using namespace std;


int main()

{

int sum = 0;

for(int i=1; i<100; i++){

if(i%7 == 0){

sum += i;

cout << "multiple of 7: " << i << " cumulative sum: " << sum << endl;

}

}

cout << "final sum: " << sum << endl;

}
LATEST TUTORIALS
APPROVED BY CLIENTS