0
Explain this code pls
#include <iostream> = 0; while (num <= 5) { cin >> number; total += number; num++; } cout << total << endl; return 0; }
2 Answers
0
When the user introduces a number greater then 4 the loop will stop. Meanwhile, it will sum the valid nums.
0
num as counter.. to add numbers entered by user
total = total + number...and finally print the total
ex: if num =0 "condition is true " user will enter number as 2, then add it to total =0+2 =2..and increment num.. so it will be 1 "still condition true"
user will enter another number as 5, add it to last total =2+5=7 and repeat steps until the condition comes false.. and finally print the total of all numbers entered by user