The sum of numbers isn't being displayed. Meanwhile, it's also not showing any compilation error.
#include <iostream>
int main()
{
int sum = 0, val = 1;
while (val <= 10);{
sum += val;
++val;
}
std::cout << sum << std::endl;
return 0;
}
It's simply not running, I'm expecting '55' to be displayed in the terminal, as the program is to add numbers from '1' to '10' both inclusive.
You added a semicolon (;
) after while
. Remove it and it works fine.