function LoopIfYouSayItHalts (bool YouSayItHalts):***/
if YouSayItHalts () then
while true do {}
else
return false;
Does this program Halt?
(Your (YES or NO) answer is to be considered
translated to Boolean as the function's input
parameter)
Please ONLY PROVIDE CORRECT ANSWERS!
On 2025-10-09 17:13:36 +0000, Bonita Montero said:
Am 09.10.2025 um 17:33 schrieb olcott:
// The pseudo code shown below has been converted
// to C compiled as C++
// the pseudo code is easier to read.
// the C code is fully operational.
/***
As I first published here back in 2004:
On 6/23/2004 9:34 PM, Olcott wrote:
***/
function LoopIfYouSayItHalts (bool YouSayItHalts):
if YouSayItHalts () then
while true do {}
else
return false;
Does this program Halt?
(Your (YES or NO) answer is to be considered
translated to Boolean as the function's input
parameter)
Please ONLY PROVIDE CORRECT ANSWERS!
#include <stdio.h>
#include <conio.h>
void LoopIfYouSayItHalts(bool YouSayItHalts)
{
if (YouSayItHalts)
while(true)
;
else
return;
}
void OutputProgram()
{
printf("\n\n\nvoid LoopIfYouSayItHalts "
"(bool YouSayItHalts)\n");
printf("{\n");
printf(" if (YouSayItHalts)\n");
printf(" while(true)\n");
printf(" ;\n");
printf(" else\n");
printf(" return;\n");
printf("}\n\n\n");
}
void Prompt()
{
char choice = 'x';
printf("Does this program Halt?\n");
printf("(Y or N) translated to Boolean argument"
" to LoopIfYouSayItHalts()\n");
printf("\nPlease ONLY PROVIDE CORRECT (Y or N) ANSWERS!\n");
while (choice != 'Y'&& choice != 'y' &&
choice != 'N' && choice != 'n')
{
choice = getch();
if (choice != 'Y'&& choice != 'y' &&
choice != 'N' && choice != 'n')
printf("Must be (Y or N)\n");
}
if (choice == 'Y' || choice == 'y')
{
printf("\nWrong Answer!\n"
"LoopIfYouSayItHalts(true) is stuck in a loop!\n\n"); >>> LoopIfYouSayItHalts(true);
}
if (choice == 'N' || choice == 'n')
{
printf("\nWrong Answer!\n"
"LoopIfYouSayItHalts(false) halts now!\n\n");
LoopIfYouSayItHalts(false);
}
}
int main()
{
OutputProgram();
Prompt();
return 0;
}
Complete idiot !
I don't think a complete idiot could write a stupid C program.
The lack of the ability to think rationally is common among
normal humans.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,073 |
Nodes: | 10 (0 / 10) |
Uptime: | 215:52:34 |
Calls: | 13,783 |
Calls today: | 1 |
Files: | 186,987 |
D/L today: |
346 files (79,246K bytes) |
Messages: | 2,434,667 |