Select Git revision
while_loop_summation.c
-
Ross Netusil authoredRoss Netusil authored
while_loop_summation.c 344 B
#include <iostream>
int main ()
{
int i;
std::cout << "please enter an integer value: ";
std::cin >> i;
int b=i;
int a=b-1;
while (a >= 1) {
b += a--;}
std::cout << "The value you entered is " << i;
std::cout << " and the sum of all whole numbers up to and including your value is " << b << ".\n";
return 0
;}