Question: Please help! Integer userNum is read from input. Write a while loop that iterates until userNum is negative. At each iteration: - Update integer finalVal

Please help!

Please help! Integer userNum is read from input. Write a while loop

Integer userNum is read from input. Write a while loop that iterates until userNum is negative. At each iteration: - Update integer finalVal as follows: - If userNum is not divisible by 5, output "lose" and do not update finalVal. - Otherwise, output "win" and increment finalVal. - Then, read an integer from input into variable userNum. End each output with a newline. Ex: If the input is 155111, then the output is: win win lose Final value is 2 Note: x%5==0 returns true if x is divisible by 5 . 567891011121314151617181920intuserNum;intfinalVal;finalVal=0;cin>>userNum;while(userNum>=0){if(userNum%5=0){finalVal+=userNum;}else{finalVal=userNum;}cin>>userNum; 1 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!