Answer to Question #262798 in C++ for naa

Question #262798

The system accepts maximum 2 input of answers for a displayed mathematical question. “WELL DONE” message is displayed for the correct answer and “TRY AGAIN” for the wrong answer. “SORRY. TIME’S UP” message is displayed if both answers are incorrect.


1
Expert's answer
2021-11-08T11:29:15-0500


#include <stdio.h>


int main()
{
    int x=5;
    int y=8;
    int user_sol;
    
    printf("2x+y= ?");
    int sol=2*x+y;
    int count=1;
    while(1){
        printf("\nEnter the solution to the mathematical equation above: ");
        scanf("%d",&user_sol);
        count++;
        if (sol==user_sol){
            printf("\nWELL DONE");
            break;
        }
        else if(sol!=user_sol && count<=2)
        {
            printf("\nTRY AGAIN");
        }
        else{
            printf("\nSORRY. TIME’S UP");
            break;
        }
        
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS