What is the output of the program: while loop, arithmetic operator - C++ Statement

C++ examples for Statement:while

Description

What is the output of the program: while loop, arithmetic operator

Demo Code

#include <iostream>
using namespace std;

int main() {//from  w  ww .  ja va2 s. c  o  m
   unsigned int x{1};
   unsigned int total{0};

   while (x <= 10) {
      int y = x * x;
      cout << y << endl;
      total += y;
      ++x;
   } 

   cout << "Total is " << total << endl;
}

Result


Related Tutorials