Hi need help ! ^^

+1 Rodrigo Lopes · February 9, 2016
Hi everyone, so i made a program which should calculate the average of your tests. however the average keeps the same! can someone help me out please? ty anyway^^

#include <stdio.h>
#include <stdlib.h>

int main()
  float notesadded = 0;
  float average = 0;
  float numberOftests = 0;
  float scoreentered = 0;
  char grade[50];

  printf("Hi this program will help you calculating your tests average!\n\a");
  printf("Whenever you want to quit the program just enter 0\n");

        printf("In %.2f tests your average is %.2f\n", &numberOftests, &average);
        printf("Enter now you new grade\n");

        scanf("%f", &scoreentered);
        notesadded += scoreentered;
        average = notesadded / numberOftests;

        if(average >= 90){
            printf("Your grade is:Excellent\n");
        }else if(average > 80){
            printf("Your grade is:Normal\n");
            printf("Your grade is:Bad\n");

  }while(scoreentered !=0);

Post a Reply


Oldest  Newest  Rating
0 Linguist Llama · February 9, 2016
Is your compiler showing you any warnings? It should be... and you should be reading them and trying to understand what they're saying... Here's what my compiler says when I try to compile your code:

C:\Users\Seb\Desktop>gcc -Wall -pedantic code.c
code.c: In function 'main':
code.c:16:8: warning: format '%f' expects argument of type 'double', but argument 2 has type 'float *' [-Wformat=]
printf("In %.2f tests your average is %.2f\n", &numberOftests, &average);
code.c:16:8: warning: format '%f' expects argument of type 'double', but argument 3 has type 'float *' [-Wformat=]
code.c:10:6: warning: unused variable 'grade' [-Wunused-variable]
char grade[50];

Do you have any questions about these warnings?
  • 1



One of the most popular languages of all time.

Bucky Roberts Administrator