How does this function work the other way?

Marco Maher

Obviously, if we write 'x < 10' then, x is smaller than 10. However, it's not the case here

int n;
do
{
    n = get_int("width");
}
while (n < 10);


for (int i = 0; i < n; i++)
{
    printf("?");
}
printf("\n");

If we wanted to print '?' the same number as the user input, it will only print when numbers are larger than 10 while it shouldn't. Because n is not smaller than 10... the loop shouldn't run.

So how is that possible?

anastaciu

...it will only print when numbers are larger than 10 while it shouldn't.

Why shouldn't it? The first loop gets an int from the user, if the user inputs a value that is smaller than 10, then it will ask the user for a new input, if the user inputs a value larger than or equal to 10 the while loop will end and n will have that value, let's say it's 15, after that the for loop will run 15times.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related