-5

From Harvard's CS50 course

basically he has a function

where he says

do {
    int n = get_int("Positive number")
}
while ;

He wants the program to repeat positive number until the user inputs a positive number. Why is the while loop on the bottom of his do function?

Barmar
  • 741,623
  • 53
  • 500
  • 612
Karan K
  • 1
  • 1

1 Answers1

0

Because he want to get a number from the user then if it was positive, he will ask for another number, do while loops execute the code within the first time without any checking, then it gets repeted if the condition was true, whereas while loop will check for the condition first, and it will execute the cod only if condition was true