Welcome to Dream.In.Code
Become a C++ Expert!

Join 136,933 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,865 people online right now. Registration is fast and FREE... Join Now!




whats wrong?

 
Reply to this topicStart new topic

whats wrong?, this program is a math trivia .i don't know what went wrong. b4 i

zanderela
17 Mar, 2008 - 07:25 AM
Post #1

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 5

#define p printf
#define s scanf
#define clr clrscr
#define g gotoxy

main()
{
int l; int y;
for(;;)
{

clr();
g(32,9);
p("MATH TRIVIA\n");
g(35,5);p("LOADING...\n");

for(y=20; y<60; y++) {
g(y,6);p("ý");
delay(1000000);}

clr();
g(37,2);p("Levels\n\n");
g(35,5);p("[1] QUESTIONS\n");
g(35,11);p("[2] QUIT\n\n");
g(33,15);p("Choose: ");
s("%d",&l);
if(l==1)
easy();
else if (l==2)
exit();
}
}
easy()
{
int x;
char d[5];
int i=1;
char a[]="a";
char b[]="b";
char c[]="c";
for(x=1;x<=3;x++)
{
clr();
g(22,9);p("Direction:");
g(22,11);p("1. What two letters are both symbols for 1,000?");
g(22,13);p("%s. K and M.",a);
g(22,15);p("%s. A and B.",b);
g(22,17);p("%s. L and D",c);
g(22,21);p("Answer: ");gets(d);
if(strcmp(d,a)==0)
{
clr();
g(22,25);p("Correct!!!\n");
g(22,27);p("Your scrore is %d",i);
x=3;
getch();
}
else
{
g(22,25);p("Wrong!!!\n");
g(22,27);p("Life[%d]",x);
getch();
}
}
for(x=1;x<=3;x++)
{
clr();
g(22,9);p("Direction:");
g(22,11);p("1. What's short for Binary Digit?");
g(22,13);p("%s. BD.",a);
g(22,15);p("%s. Bit.",b);
g(22,17);p("%s. Digit.",c);
g(22,21);p("Answer: ");gets(d);
if(strcmp(d,b)==0)

{
g(22,25);p("Correct!!!\n");
i=i+1;
g(22,27);p("Your scrore is %d",i);
x=3;
getch();
}
else
{
g(22,25);p("Wrong!!!\n");
g(22,27);p("Life[%d]",x);
getch();
}
}
}
User is offlineProfile CardPM
+Quote Post

MorphiusFaydal
RE: Whats Wrong?
17 Mar, 2008 - 07:29 AM
Post #2

D.I.C Lover
Group Icon

Joined: 12 May, 2005
Posts: 1,112



Thanked: 9 times
Expert In: Hardware, Networking

My Contributions
Okay, what's your question? We're not mind readers. smile.gif

Also, code.gif
User is offlineProfile CardPM
+Quote Post

zanderela
RE: Whats Wrong?
17 Mar, 2008 - 07:49 AM
Post #3

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 5

sorry i did not know how to put this but here is my question. what seems to be the problem with my code.? before i put my choice of letter theres already a remark that my answer is wrong..Where did i go wrong? here is the code. :)

CODE
#define p printf
#define s scanf
#define clr clrscr
#define g gotoxy

main()
{
    int l; int y;
    for(;;)
    {

    clr();
    g(32,9);
    p("MATH TRIVIA\n");
    g(35,5);p("LOADING...\n");

    for(y=20; y<60; y++) {
    g(y,6);p("ý");
    delay(1000000);}

    clr();
    g(37,2);p("Levels\n\n");
    g(35,5);p("[1] QUESTIONS\n");
    g(35,11);p("[2] QUIT\n\n");
    g(33,15);p("Choose:  ");
    s("%d",&l);
    if(l==1)
    easy();
    else if (l==2)
    exit();
    }
}
easy()
{
    int x;
    char d[5];
    int i=1;
    char a[]="a";
    char b[]="b";
    char c[]="c";
    for(x=1;x<=3;x++)
    {
    clr();
    g(22,9);p("Direction:");
    g(22,11);p("1. What two letters are both symbols for 1,000?");
    g(22,13);p("%s. K and M.",a);
    g(22,15);p("%s. A and B.",b);
    g(22,17);p("%s. L and D",c);
    g(22,21);p("Answer: ");gets(d);
    if(strcmp(d,a)==0)
    {
    clr();
    g(22,25);p("Correct!!!\n");
    g(22,27);p("Your scrore is %d",i);
    x=3;
    getch();
    }
    else
    {
    g(22,25);p("Wrong!!!\n");
    g(22,27);p("Life[%d]",x);
    getch();
    }
    }
    for(x=1;x<=3;x++)
    {
    clr();
    g(22,9);p("Direction:");
    g(22,11);p("1. What's short for Binary Digit?");
    g(22,13);p("%s. BD.",a);
    g(22,15);p("%s. Bit.",b);
    g(22,17);p("%s. Digit.",c);
    g(22,21);p("Answer: ");gets(d);
    if(strcmp(d,b)==0)

    {
    g(22,25);p("Correct!!!\n");
    i=i+1;
    g(22,27);p("Your scrore is %d",i);
    x=3;
    getch();
    }
    else
    {
    g(22,25);p("Wrong!!!\n");
    g(22,27);p("Life[%d]",x);
    getch();
    }
    }
}  

User is offlineProfile CardPM
+Quote Post

zanderela
RE: Whats Wrong?
17 Mar, 2008 - 08:02 AM
Post #4

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 5

help. my code doesn't work propperly. everything seems to be good at first but by the time i key in my answer, theres already a remark that my answer is wrong. how can i remove it? and how can i put the score at the end of the game? thnx:)

CODE
#define p printf
#define s scanf
#define clr clrscr
#define g gotoxy

main()
{
    int l; int y;
    for(;;)
    {

    clr();
    g(32,9);
    p("MATH TRIVIA\n");
    g(35,5);p("LOADING...\n");

    for(y=20; y<60; y++) {
    g(y,6);p("ý");
    delay(1000000);}

    clr();
    g(37,2);p("Levels\n\n");
    g(35,5);p("[1] QUESTIONS\n");
    g(35,11);p("[2] QUIT\n\n");
    g(33,15);p("Choose:  ");
    s("%d",&l);
    if(l==1)
    easy();
    else if (l==2)
    exit();
    }
}
easy()
{
    int x;
    char d[5];
    int i=1;
    char a[]="a";
    char b[]="b";
    char c[]="c";
    for(x=1;x<=3;x++)
    {
    clr();
    g(22,9);p("Direction:");
    g(22,11);p("1. What two letters are both symbols for 1,000?");
    g(22,13);p("%s. K and M.",a);
    g(22,15);p("%s. A and B.",b);
    g(22,17);p("%s. L and D",c);
    g(22,21);p("Answer: ");gets(d);
    if(strcmp(d,a)==0)
    {
    clr();
    g(22,25);p("Correct!!!\n");
    g(22,27);p("Your scrore is %d",i);
    x=3;
    getch();
    }
    else
    {
    g(22,25);p("Wrong!!!\n");
    g(22,27);p("Life[%d]",x);
    getch();
    }
    }
    for(x=1;x<=3;x++)
    {
    clr();
    g(22,9);p("Direction:");
    g(22,11);p("1. What's short for Binary Digit?");
    g(22,13);p("%s. BD.",a);
    g(22,15);p("%s. Bit.",b);
    g(22,17);p("%s. Digit.",c);
    g(22,21);p("Answer: ");gets(d);
    if(strcmp(d,b)==0)

    {
    g(22,25);p("Correct!!!\n");
    i=i+1;
    g(22,27);p("Your scrore is %d",i);
    x=3;
    getch();
    }
    else
    {
    g(22,25);p("Wrong!!!\n");
    g(22,27);p("Life[%d]",x);
    getch();
    }
    }
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 10:39PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month