When i run my program it runs fine untill the end when its suppose to calculate all the data instead it starts the program all over again. My code is below i also tried fflush(stdout); fflush(stdin); after each scanf line and that does the same thing as this:
[code]
#include <stdio.h>
int main()
{
float hundredthirteen = 113.0;
float decimal = 0.096;
float five= 5.0;
float scoreone, rating, slope;
float scoretwo, ratingtwo, slopetwo;
float scorethree, ratingthree, slopethree;
float scorefour, ratingfour, slopefour;
float scorefive, ratingfive, slopefive;
float partone, parttwo, partthree, handicapone;
float partonetwo, parttwotwo, partthreetwo, handicaptwo;
float partonethree, parttwothree, partthreethree, handicapthree;
float partonefour, parttwofour, partthreefour, handicapfour;
float partonefive, parttwofive, partthreefive, handicapfive;
float partfour, handicapindex;
int c;
printf("You will enter your last five golf scores and this will find your handicap index");
printf("Score 1: What did you shoot? ");
scanf(" %f", scoreone);
((c = getchar()) != '\n' && c != EOF) ;
printf("What is the course rating? ");
scanf(" %f", rating);
((c = getchar()) != '\n' && c != EOF) ;
printf("What is the course slope? ");
scanf(" %f", slope);
((c = getchar()) != '\n' && c != EOF) ;
partone = scoreone - rating;
parttwo = partone * hundredthirteen;
partthree = parttwo / slope;
handicapone = partthree * decimal;
printf("\nScore 2: What did you shoot? ");
scanf(" %f", &scoretwo);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course rating? ");
scanf(" %f", &ratingtwo);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course slope? ");
scanf(" %f", &slopetwo);
((c = getchar()) != '\n' && c != EOF) ;
partonetwo = scoretwo - ratingtwo;
parttwotwo = partonetwo * hundredthirteen;
partthreetwo = parttwotwo / slopetwo;
handicaptwo = partthreetwo * decimal;
printf("\nScore 3: What did you shoot? ");
scanf(" %f", &scorethree);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course rating? ");
scanf(" %f", &ratingthree);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course slope? ");
scanf(" %f", &slopethree);
((c = getchar()) != '\n' && c != EOF) ;
partonethree = scorethree - ratingthree;
parttwothree = partonethree * hundredthirteen;
partthreethree = parttwothree / slopethree;
handicapthree = partthreethree * decimal;
printf("\nScore 4: What did you shoot? ");
scanf(" %f", &scorefour);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course rating? ");
scanf(" %f", &ratingfour);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course slope? ");
scanf(" %f", &slopefour);
((c = getchar()) != '\n' && c != EOF) ;
partonefour = scorefour - ratingfour;
parttwofour = partonefour * hundredthirteen;
partthreefour = parttwofour / slopefour;
handicapfour = partthreefour * decimal;
printf("\nScore 5: What did you shoot? ");
scanf(" %f", &scorefive);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course rating? ");
scanf(" %f", &ratingfive);
((c = getchar()) != '\n' && c != EOF) ;
printf("\nWhat is the course slope? ");
scanf(" %f", &slopefive);
((c = getchar()) != '\n' && c != EOF) ;
partonefive = scorefive - ratingfive;
parttwofive = partonefive * hundredthirteen;
partthreefive = parttwofive / slope;
handicapfive = partthreefive * decimal;
partfour = handicapone + handicaptwo + handicapthree + handicapfour + handicapfive;
handicapindex = partfour / five;
printf(" Your handicap index is %f", handicapindex);
return 0;
}
[\code]