Trusted by Students Everywhere
Why Choose Us?
0% AI Guarantee

Human-written only.

24/7 Support

Anytime, anywhere.

Plagiarism Free

100% Original.

Expert Tutors

Masters & PhDs.

100% Confidential

Your privacy matters.

On-Time Delivery

Never miss a deadline.

Why would a programmer intentionally code the following line into a program? (Code needed to make this a complete program intentionally left out

Computer Science Sep 02, 2020

Why would a programmer intentionally code the following line into a program? (Code needed to make this a complete program intentionally left out.)

#define true 1
while(true)
{
// Stuff inside loop.
}

Expert Solution

"Why would a programmer intentionally code the following line into a program?"
- For instance when a program needs to prompt the user for an operation (from a menu) this kind of loops are used. Or an embedded system checks periodically (in this kind of loops) all needed buffers (operations required) and acts accordingly.

Below is a complete code (also attached):

#include

#define true 1

char* s_pMenu = "Select operation:n"
"1 - Add Numbersn"
"2 - Subtract Numbersn"
"3 - Exitn";

int main()
{
int nOp ;
while(true)
{
// Stuff inside loop.
printf (s_pMenu) ;
scanf ("%d", &nOp) ;

switch (nOp)
{
case 1: printf ("Add numbers selectedn") ; break ;
case 2: printf ("Subtract numbers selectedn") ;break ;
case 3: return 0 ; break ;
default: printf ("Wrong operation. Try again!n") ; break ;
}
}

return 0;
}

Archived Solution
Unlocked Solution

You have full access to this solution. To save a copy with all formatting and attachments, use the button below.

Already a member? Sign In
Important Note: This solution is from our archive and has been purchased by others. Submitting it as-is may trigger plagiarism detection. Use it for reference only.

For ready-to-submit work, please order a fresh solution below.

Or get 100% fresh solution
Get Custom Quote
Secure Payment