well i made a somewhat msconsole code to calculate the probability of dice rolls.. first i did it without using functions. but when i made it with functions, its stuffing up.. for some reason my function calcTotal isnt doint its job properly...

here is the code

Code:

#include <stdio.h>
#include <stdlib.h>
void printHeader(void);
float calcTotal(int);
float calcPercent(float,float);
int askDice(void);
int askThrows(void);
int main()
{
float total=0;
float percentage=0;
int dice=0;
float maxthrows=0;
int maxtarget=0;
float hits=0;
dice=askDice();
maxthrows=askThrows();
maxtarget=dice*6;
printf("Target\tHits\tPercentage\n");
for (int target=2; target<=maxtarget; target++)
{
for (int throws=0; throws<=maxthrows; throws++)
{
total=calcTotal(dice);
if (total=target)
{
hits=hits+1;
}
}
printf("%d\t%.0f\t%.2f\n",target,hits,percentage);
hits=0;
}
percentage=calcPercent(hits,maxthrows);
return 0;
}
int askDice(void)
{
int dice=0;
printf("Please enter the number of dice you wish to throw: ");
scanf("%d%*c",&dice);
return(dice);
}
int askThrows(void)
{
int maxthrows;
printf("How many throws would you like to make?: ");
scanf("%d%*c",&maxthrows);
return(maxthrows);
}
float calcTotal(int argdice)
{
float total=0;
for (float x=1; x<=argdice;x++)
{
int randchar;
randchar=(rand()%6)+1;
total=total+randchar;
}
return(total);
}
float calcPercent(float arghits, float argthrows)
{
float percent=0;
percent=(arghits/argthrows)*100;
return (percent);
}

so where did i go wrong?

it basically asks you how many number of dices you want to roll and how many throws do you want... then it calculates the probability of each value on the number of dice rolls you inputed.