Problem with Windows and C

0

Today I decided to learn C, I'm creating a very basic program that took the average of 4 numbers that are entered into the program:

#include <stdio.h>
void main(){
    int calif1, calif2, calif3, calif4, total;
    printf(" introduzca el valor de la primera nota: ");
    scanf("%i", calif1);
    printf("\n introduzca el valor de la segunda: ");
    scanf("%i",calif2);
    printf("\n introduzca el valor de la tercera: ");
    scanf("%i",calif3);
    printf("\n introduzca el valor de la cuarta: ");
    scanf("%i",calif4);
    total = calif1 + calif2 + calif3 + calif4;
    printf("el promedio es: %i",total/4);
}

after compiling with TDM-GCC 4.9.2 64-bit (I do not know if this information helps you) I got this message from windows:

What can I do and what is due?

    
asked by binario_newbie 06.04.2018 в 03:05
source

1 answer

1

When using scanf you need to pass the reference of the variable in case it is not a pointer or an array, this is achieved through the use of the ampersand (&).

scanf("%i", &calif1);
#include <stdio.h>

int main()
{
    int calif1, calif2, calif3, calif4, total = 0;
    printf(" introduzca el valor de la primera nota: ");
    scanf("%i", &calif1);
    printf("\n introduzca el valor de la segunda: ");
    scanf("%i", &calif2);
    printf("\n introduzca el valor de la tercera: ");
    scanf("%i", &calif3);
    printf("\n introduzca el valor de la cuarta: ");
    scanf("%i", &calif4);
    total = calif1 + calif2 + calif3 + calif4;
    printf("el promedio es: %i",total/4);

    return 0;
}
    
answered by 06.04.2018 / 03:43
source