Ask Question

Write a while loop that prints 1 to user_num. Sample output for the given program: 1 2 3 4

+5
Answers (2)
  1. 21 October, 17:29
    0
    So the given program: 1 2 3 4

    i=1

    User num=4#assume positive

    While (user-num>=i);

    print (i)

    i+=1

    #include

    using namespace std;

    int main ()

    {int userNum=0;

    int i=0;

    userNum=4; ##assume positive

    i=1;

    while (i <=userNum) {

    cout<>" ";

    i=i+1;

    cout <
    return0; }
  2. 21 October, 17:35
    0
    Given 1234

    i=1

    user num=4#assume positive

    while (user-num>=i);

    print (i)

    i+=1

    #include

    using namespace std;

    int main ()

    {int userNum=0;

    int i=0;

    userNum=4; ##assume positive

    i=1;

    while (i <=userNum) {

    cout<>" ";

    i=i+1;

    cout <
    return0;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a while loop that prints 1 to user_num. Sample output for the given program: 1 2 3 4 ...” in 📗 Computers & Technology 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