Hey guys, so I started to learn a little C from numerous different sources and Iv'e hit a little "bump". When following a simple tutorial of how to make a average calculator with 5 inputs I decided I wanted to make it a little more advanced, and have a unlimited amount of inputs. I know what I have done wrong(As pointed out in "comments" in the code), but not sure how to correct it. Could you guys have a little look and in very basic terms tell me how to fix it, thanks.
Code:
#include <stdio.h>
#include <conio.h>
int main(void)
{
int loopcount;
int numbers;
int total;
int average;
int numtoav;
/* ^^ Number's to average */
int mainvar;
total=0;
loopcount=0;
{
printf("How many numbers do you want to average?");
scanf ("%d, &numtoav");
}
while(loopcount< &numtoav){
/* Problem's persisst here ^^ */
printf ("Enter the numbers you want to average");
scanf("%d", &numbers);
total = total + numbers;
loopcount=loopcount+1;
}
average = total/&numtoav;
/*Aswell as here ^^ */
printf("The average of your numbers is: %d", average);
getch ();
}
Also any tips on bad coding etiquette would be also appreciated.