-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMagicalMath.c
More file actions
50 lines (45 loc) · 1.53 KB
/
Copy pathMagicalMath.c
File metadata and controls
50 lines (45 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,a,b,num,result;
char ans[3];
initgraph(&gd,&gm,"c:\\Turboc3\\bgi"); //initiate the graphics mode
a=getmaxx()/5;
b=getmaxy()/2;
setbkcolor(GREEN);//set the background color
settextstyle(0,0,4);
outtextxy(a,b,"\2 Magic Math \2");
delay(1000);
cleardevice();
settextstyle(0,0,2);
outtextxy(a/2,b,"* Read the instruction carefully *");
delay(1000);
cleardevice();
settextstyle(0,0,1);
//Instructions to play the magic
outtextxy(50,50,"1.Assume any three digit number");
outtextxy(50,75,"2.Make sure the last number is less than first number");
outtextxy(50,100,"3.Reverse the assumed number");
outtextxy(60,125,"( Eg. if 572 is an assumed number, then 275 will be reversed number)");
outtextxy(50,150,"4.Subtrat the reversed number from assumed number( Eg. Here 572-275=297)");
outtextxy(50,175,"5.Keep the answer in your mind");
outtextxy(50,200,"6.You need to enter the last digit of your answer alone");
outtextxy(60,225,"(Eg. Here 7 is the last digit in 297 )");
outtextxy(100,250,"Click Enter key,when you red out it..");
getch();
cleardevice();
outtextxy(a,100,"Enter the last digit of your answer..");
scanf("%d",&num);//get the data from player
cleardevice();
settextstyle(0,0,3);
result=num+90+(9-num)*100;//mathematical calculation to find the answer
outtextxy(a,b,"Hurray!We got it");
outtextxy(a,b+30,"Your answer is");
itoa(result,ans,10);
outtextxy(250,b+60,ans);
getch();
}