Ask Question
30 January, 03:38

Complete the do-while loop to output every number from 0 to countlimit using printval. assume the user will only input a positive number. for example, if countlimit is 5 the expected output will be 0 1 2 3 4 5

+2
Answers (1)
  1. 30 January, 04:03
    0
    Hi, here's a do-while loop using C + + programming language.

    int countlimit; / / input from user

    int printval = 0; / / initial value of printval

    cout<<"Enter a positive number:"; / / suppose user inputs 5

    cin>>countlimit; / / value 5 will be stored inside variable countlimit

    do{ / / start of do-while loop

    cout<
    printval++; / / increment printval

    }while (printval>=countlimit); / / if condition is true, loops back to beginning of do

    Loops ends and stops printing if countlimit (of 5, in this example) is reached.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Complete the do-while loop to output every number from 0 to countlimit using printval. assume the user will only input a positive number. ...” in 📗 Mathematics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers