is to find a different way to write out the code in the whil
is to find a different way to write out the code in the while loop from class today:
sum = sum + x; // add x to the previous sum value
x = x + 1; // increment x
The \"+\" is called the \"addition operator\" which means it adds two numbers together (normally). The \"=\" is called the \"assignment operator\" which stores a value (the right-hand side) in a variable (the left-hand side). You are NOT allowed to use either operator.
Solution
The given code is implemented without using + and = which is addition and assignment operator.
while(x>=condition) //condition will be the value at which the program terminates.
{
sum+=x; // += is equivalent to sum=sum+x;
x++; // ++ is postfix unary operator,
}
if you like this answer, please give a thumbs up and if you have some doubt just ask in the comment section below. I will try to help. Cheers
