C
claymic
I am trying to complete some math tutorials, and wanted to write an
answer generator in C.
The type of question is;
"A doll costs $20, a toy car costs $6, a yoyo costs $1.
What combination of toys will allow you to by 100 toys for $200?"
So far I have:
#include <stdio.h>
#define DOLL 20
#define CAR 6
#define YOYO 1
#define TOTALCASH 200
#define TOTALNUM 100
void main (void)
{
int cost;
int numb_tops;
int numb_dolls;
int numb_cars;
printf("A doll costs $%i.00, a car costs $%i.00, and a yoyo costs
$%i.00\n", DOLL, CAR, YOYO);
printf("With $%i.00 dollars you can buy %i toys, \nif you buy the
following;\n", TOTALC, TOTALN);
for(cost = 0; numbert < TOTALN & cost < TOTALC; )
}
But I cannot figure out the loops needed to compute the answer.
I am looking to make this into a function to be called when a system
of equations needs to be solved.
Thanks
answer generator in C.
The type of question is;
"A doll costs $20, a toy car costs $6, a yoyo costs $1.
What combination of toys will allow you to by 100 toys for $200?"
So far I have:
#include <stdio.h>
#define DOLL 20
#define CAR 6
#define YOYO 1
#define TOTALCASH 200
#define TOTALNUM 100
void main (void)
{
int cost;
int numb_tops;
int numb_dolls;
int numb_cars;
printf("A doll costs $%i.00, a car costs $%i.00, and a yoyo costs
$%i.00\n", DOLL, CAR, YOYO);
printf("With $%i.00 dollars you can buy %i toys, \nif you buy the
following;\n", TOTALC, TOTALN);
for(cost = 0; numbert < TOTALN & cost < TOTALC; )
}
But I cannot figure out the loops needed to compute the answer.
I am looking to make this into a function to be called when a system
of equations needs to be solved.
Thanks