d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C Programming > Change My Program
12Next
Add Reply New Topic New Poll
Member
Posts: 51
Joined: Feb 7 2013
Gold: 0.00
Feb 19 2013 01:50pm
How would I edit this to keep track of the questions answered

Code
#include <stdlib.h>
#include <time.h>
#include <stdio.h>

main ()
{
    int x, iNumQuestions, iResponse, iRndNum1, iRndNum2,;
    srand(NULL);
   
    printf("\nEnter number of questions to ask: ");
    scanf("%d", &iNumQuestions);
   
    for ( x = 0; x < iNumQuestions; x++ ) {
       
        iRndNum1 = rand() % 10 + 1;
        iRndNum2 = rand() % 10 + 1;
       
        printf("\nWhat is %d x %d: ", iRndNum1, iRndNum2);
        scanf("%d", &iResponse);
       
        if ( iResponse == iRndNum1 * iRndNum2 )
        printf("\nCorrect!\n");
        else
        printf("\nThe correct answer was %d \n", iRndNum1 * iRndNum2);
        system("pause");
        }
        }
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 19 2013 02:30pm
are you seriously that retarded that you can write this much code and not know how to do this?

declare an integer value and simple increment it based on what you want. aka if you want correct questions answered you would put the incremented variable after the printf statement saying correct.

also if you dont know how to increment an integer its simple

Code
varname++;


This post was edited by AbDuCt on Feb 19 2013 02:31pm
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Feb 19 2013 02:34pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Feb 19 2013 03:34pm
Quote (AbDuCt @ Feb 19 2013 04:30pm)
are you seriously that retarded that you can write this much code and not know how to do this?

declare an integer value and simple increment it based on what you want. aka if you want correct questions answered you would put the incremented variable after the printf statement saying correct.

also if you dont know how to increment an integer its simple

Code
varname++;


just to clarify

VARIABLE INCREMENTING IS STANDARD AND EXACTLY THE SAME IN BOTH C AND C++

just in case you think C is any different.
Member
Posts: 51
Joined: Feb 7 2013
Gold: 0.00
Mar 12 2013 05:31pm
Quote (AbDuCt @ Feb 19 2013 04:34pm)
just to clarify

VARIABLE INCREMENTING IS STANDARD AND EXACTLY THE SAME IN BOTH C AND C++

just in case you think C is any different.


btw im happy to report I got this on my own no thanx to ya ppl

Code
// math quiz counting answered correctly answered

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

main ()
{

int x, iNumQuestions, iResponse, iRndNum1, iRndNum2,;
int AnsweredCorrect = 0;
srand (time(NULL));

printf("\nEnter number of questions to ask: ");
scanf("%d", &iNumQuestions);

for ( x = 0; x < iNumQuestions; x++ )
{

iRndNum1 = rand() % 10 + 1;
iRndNum2 = rand() % 10 + 1;

printf("\nWhat is %d x %d: ", iRndNum1, iRndNum2);
scanf("%d", &iResponse);

if ( iResponse == iRndNum1 * iRndNum2 )
printf("\nCorrect!\n"), AnsweredCorrect++;
else
printf("\nThe correct answer was %d \n", iRndNum1 * iRndNum2);
} // end loop
printf ("\nThe amount of questions you have answered correctly is %d \n", AnsweredCorrect);
system("pause");
} // end main function
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 13 2013 12:41am
Quote (Xarai @ Mar 12 2013 07:31pm)
btw im happy to report I got this on my own no thanx to ya ppl

Code
// math quiz counting answered correctly answered

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

main ()
{

int x, iNumQuestions, iResponse, iRndNum1, iRndNum2,;
int AnsweredCorrect = 0;
srand (time(NULL));

printf("\nEnter number of questions to ask: ");
scanf("%d", &iNumQuestions);

for ( x = 0; x < iNumQuestions; x++ )
{

iRndNum1 = rand() % 10 + 1;
iRndNum2 = rand() % 10 + 1;

printf("\nWhat is %d x %d: ", iRndNum1, iRndNum2);
scanf("%d", &iResponse);

if ( iResponse == iRndNum1 * iRndNum2 )
printf("\nCorrect!\n"), AnsweredCorrect++;
else
printf("\nThe correct answer was %d \n", iRndNum1 * iRndNum2);
} // end loop
printf ("\nThe amount of questions you have answered correctly is %d \n", AnsweredCorrect);
system("pause");
} // end main function


i am glad i showed you how to increment a variable to get it done as stated in the post you quoted.

just leave this place please... we are not here to spoon feed you.

This post was edited by AbDuCt on Mar 13 2013 12:41am
Member
Posts: 51
Joined: Feb 7 2013
Gold: 0.00
Mar 13 2013 06:28pm
Quote (AbDuCt @ Mar 13 2013 01:41am)
i am glad i showed you how to increment a variable to get it done as stated in the post you quoted.

just leave this place please... we are not here to spoon feed you.


your right you dont spoon feed, you dont help anyone either.
however I guess you don't realize but that's why people post questions asking for help they are seeking out guidance or help because there is none in their physical vicinity
We don't need people flaming, trolling, etc we just ask for help. I guess what I am saying is
If you see someone on the road shot or ran over do you
A. call them a dumbass and stfu and help themselves and walk away
B Call 911, help stop the bleeding and keep them calm and healthy
C. Nothing, just ignore them they don't exist
D. laugh at how stupid they are for getting shot in the first place

sadly A,C,D are all the reactions I have seen on the forums

This post was edited by Xarai on Mar 13 2013 06:28pm
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 13 2013 08:05pm
Quote (Xarai @ Mar 13 2013 08:28pm)
your right you dont spoon feed, you dont help anyone either.
however I guess you don't realize but that's why people post questions asking for help they are seeking out guidance or help because there is none in their physical vicinity
We don't need people flaming, trolling, etc we just ask for help. I guess what I am saying is
If you see someone on the road shot or ran over do you
A. call them a dumbass and stfu and help themselves and walk away
B Call 911, help stop the bleeding and keep them calm and healthy
C. Nothing, just ignore them they don't exist
D. laugh at how stupid they are for getting shot in the first place

sadly A,C,D are all the reactions I have seen on the forums


you put forth no effort to solve these problems yourself. how can you say we dont help when we give you the answers clear as day. it falls upon you to comprehend them and utilize what we say, but instead we get responses like "its broken" "it doesnt run" "it wont work"

Quote (AbDuCt @ Feb 19 2013 04:30pm)

declare an integer value and simple increment it based on what you want. aka if you want correct questions answered you would put the incremented variable after the printf statement saying correct.

also if you dont know how to increment an integer its simple

Code
varname++;


besides me calling you retarded in that post that was the correct answer to your problem, but you were unable to comprehend how to use it i guess. we normally do tell you how to do things but you expect people to pick up your code throw it through a compiler and debugger and fix it for you. that just doesnt happen around here.
Member
Posts: 51
Joined: Feb 7 2013
Gold: 0.00
Mar 14 2013 11:20am
short of calling you an ignorant bigot (seems that actually fits selftaught) I have clear as day said my problem, however I guess you don't understand I am in a learning environment.
What this means is we are taught a limited amount of programming, we can't use features in future chapters. We are allowed to use 1 (one) program dev c++ to compile,debug, and run our program and nothing else
I asked a few probs on my prototype, You said it was a-ok but apaprently you didnt notice the comparison DIDNT HAVE A CALL FUNCTION!
I am not expecting you to flat out answer everything but god damn I expect a itty bitty bit of help
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 14 2013 12:33pm
Quote (Xarai @ Mar 14 2013 01:20pm)
short of calling you an ignorant bigot (seems that actually fits selftaught) I have clear as day said my problem, however I guess you don't understand I am in a learning environment.
What this means is we are taught a limited amount of programming, we can't use features in future chapters. We are allowed to use 1 (one) program dev c++ to compile,debug, and run our program and nothing else
I asked a few probs on my prototype, You said it was a-ok but apaprently you didnt notice the comparison DIDNT HAVE A CALL FUNCTION!
I am not expecting you to flat out answer everything but god damn I expect a itty bitty bit of help


but the thing is what i said was not from any other chapter and you actually used it yourself inside your for loop. you just dont understand what we say half the time.

also ask your teacher to teach you to use the debugger it will save you and us allot of time.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll