This is an example in the C language iteration part, but I don't know why it doesn't work as intended.

Asked 2 years ago, Updated 2 years ago, 27 views

int main() { int min, val; min = INT_MAX; // Maximum value of int type constant

printf ("Enter an integer\nExit Ctrl+z\n");
while (scan("%d", &val)! = EOF) //Ctrl+z Enter to exit the repeat statement
{
    if (val < min)
        min = val;
}
printf ("minimum value is %d\n", min);
return 0;

}

//If you type Ctrl+z during execution, it will not exit. Help me.

c

2022-09-22 16:56

1 Answers

If the operating system is unix/linux, the ctrl+z signal is the end of the process.

Loop termination must be made with different conditions.


2022-09-22 16:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.