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

2 Answers

7 votes

Answer:

So the given program: 1 2 3 4

i=1

User num=4#assume positive

While (user-num>=i);

print(i)

i+=1

#include <iostream>

using namespace std;

int main()

{int userNum=0;

int i=0;

userNum=4; ##assume positive

i=1;

while (i <=userNum){

cout<<i>>" ";

i=i+1;

cout <<endl;

return0;}



User Alonad
by
8.0k points
0 votes
Given 1234
i=1
user num=4#assume positive
while (user-num>=i);
print(i)
i+=1
#include <iostream>
using namespace std;
int main()
{int userNum=0;
int i=0;
userNum=4; ##assume positive
i=1;
while (i <=userNum){
cout<<i>>" ";
i=i+1;
cout <<endl;
return0;
}
User HiBrianLee
by
8.1k points