0
Good evening, I have a doubt in the code I made below, my teacher requested that the values name, ra, n1,N2 be read and be displayed to the average of 40 students, I’m trying to put when I try to run my program is not calculating the media and gets doesn’t work and only shows a character instead of the full name
#include<stdio.h>
#include<stdlib.h>
int main(){
char nome[50];
int i=0,j=0,k=0,l=0,m=0;
float n1[39],n2[39],ra[39],media[39];
for (i=0;i<40;i++){
printf("Insira o nome: ");
gets("%s",&nome[i]);
}
for (j=0;j<40;j++){
printf("Insira o RA: ");
scanf("%d",&ra[j]);
}
for (k=0;k<40;k++){
printf("Informe a primeira nota do %d aluno",k+1);
scanf("%d",&n1[k]);
}
for (l=0;l<40;l++){
printf("Informe a segunda nota do %d: ",l+1);
scanf("%d",&n2[l]);
}
for (m=0;m<40;m++){
media[39] = (n1[k] * n2[l])/2;
printf("o aluno %s ra numero:%d teve a media %d
",nome[i],ra[j],media[m]);
}
}
}
Try to use like this:
gets(nome[i])
– Francisco