need help with simple problem

Soldato
Joined
9 Dec 2006
Posts
9,289
Location
@ManCave
im making a random maths game (first app)

PHP:
int number1 = rand() % 25;
int number2 = rand() % 30;
int USER;
int CPU = ("%d"*"%d", &USER ,&CPU);
printf("what is %d times %d\n",number1, number2);
printf("Enter Your Answer: ");
scanf("%d", &USER);

im having trouble with int CPU
can anyone tell me how to mutiply to variables together correctly?

also would you say this is a clean program so far?
 
thanks i did work it out just before you posted, i come across another problem now,

i played around with it but not got it right yet

PHP:
// loop.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
int _tmain(int argc, _TCHAR* argv[])
{
/*declare your varibles*/ 
int number1 = rand() % 25;
int number2 = rand() % 30;
int USER;
int CPU = (number1*number2);
int Questions;
int QN;
printf("How many questions would you like to answer?");
scanf("&d",Questions);
for (QN = 0; QN < "%d",Questions; QN++ ) {
printf("what is %d times %d\n",number1, number2);
printf("Enter Your Answer: ");
scanf("%d", &USER);
if ("%d" == "%d" ,USER,CPU){
printf("You are Right\n");
}
else {
printf("You are wrong\n");
}
printf("Next Question");
}


getchar();
return 0;
}
 

im trying to loop the question around for as many times as user input to answer,

im going though the c programming tutorail but does show how to do this.

if you wish to help please do :)
 
yeh i tried that at first and failed so tried %d lol

retried it as suggested and works correctly thanks!,

i think i forgot the space between < and questions

now just got work out why the if statement doesnt work :)

keeps saying your right on every question..
 
Back
Top Bottom