-
simple c question
some of you may have looked at my earlier post, basically, i'm making a ecosystem simulation based on the following mathematical model -
(a/b*c) -(d/e*c)+(a/b*c)
there is a ? out of ? chance that an animal will be created, and a ? out of ? chance that something will be destroyed. the math model basically just shows the final amount of animals.
so far what i've got -
Code:
#include <stdio.h>
main()
{
float a,b,c,d,e,f,g,h,i;
printf("number of seconds");
scanf ("%d",&c);
printf("first number for creation");
scanf("%d",&a);
printf("second number of creation");
scanf("%d",&b);
printf("first number of destruction");
scanf("%d",&d);
printf("second number of desturction");
scanf("%d",&e);
f=(a/b*c) -(d/e*c) +(a/b*c);
printf("the final amount is %d\n",f);
}
i've tried so many different things...and yet nothing works...
help!!!
thanks in advance,
JOlszewski
-
-
Thats what I was about to say. Your identifiers are set up as floating point numbers :
Yet when you call them in your code, you are accessing them as integers:
Your basicaly confusing the program.
Code:
#include <stdio.h>
main()
{
float a,b,c,d,e,f;
printf("number of seconds\t");
scanf_s("%f",&c);
printf("first number for creation\t");
scanf_s("%f",&a);
printf("second number of creation\t");
scanf_s("%f",&b);
printf("first number of destruction\t");
scanf_s("%f",&d);
printf("second number of desturction\t");
scanf_s("%f",&e);
f=(a/b*c)-(d/e*c)+(a/b*c);
printf("the final amount is %f\n",f);
}