ok this is silly . i know i am rookie in this so please help me out

+1 imran LP · February 3, 2015
int main()
{
    float grade=0;
    float scoreEntered = 0;
    float numberOfTests=0;
    float average = 0;
    printf("press 0 when completed\n \n");

    do
    {
        printf("tests: %.0f    average: %.2f\n", numberOfTests, average);
    printf("\nenter your test score here: \n");
    scanf("%f\n",&scoreEntered);
    grade+=scoreEntered;
    numberOfTests++;
    average=grade/numberOfTests;

    } while(scoreEntered!=0);
    return 0;
}




this is my source code . when am running it idk why it doesnt execute at first time . i mean if i enter 70 for the first time it doest respond and then when i again enter a value , that is when it starts working properly . help me out


/images/forum/upload/2015-02-03/f6f04b5233a2d01a81ffa9972e81bbff.PNG



Post a Reply

Replies

Oldest  Newest  Rating
+2 c student · February 3, 2015
try deleting that \n in your scanf
+1 imran LP · February 3, 2015
yeah it worked now . Thank you :)
+2 J show · February 3, 2015
I've noted when using \n either dont use it at all when getting info from users or only use it in the printf statement because the user will hit enter when they input their information
+1 imran LP · February 4, 2015
hmm okay Josh Showalter i get it :) thanks.
+1 J show · February 8, 2015
haha okay:) i'm new to though i've only been programming for prolly 3 months so trying to learn and share everything i can ha
  • 1

C

107,322 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator