by Dinesh Thakur Category: C Programming (Pratical)

 This is C Program Write a Magic Number Program. In this program user ask to guess whether the guessed number is correct or not. The casually in this program the Control Statement will be used like if-else. If the guessed number is equal to the number that set for variable then it’s right else it will be wrong the variable declared which use to contain the given value for condition checks out. After the condition got completed the result will be on the display.

Problem Statement:
This is the program to check out the magic number from guessing digit.

  1. Enter the digit for check.
  2. Execute the control statement.
  3. Display result on the screen

Here is source code of the C program to check out the magic number from guessing digit. The C program is successfully compiled. The program output is also shown below.

#include<stdio.h>

void main()
{
       int magic =23;
       int guess;
       clrscr();
       printf("Enter your Guess for the Number : ");
       scanf("%d",& guess);
       if(guess==magic)
        {
            printf("\nCongratulation Right Guess");
        }
      else
       {
            printf("\nSorry Wrong Guess");
       }
            getch();
}
Output :
Enter your Guess for the Number : 23
Congratulation Right Guess


About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.