0
I don’t know where I’m going wrong.
#include <stdio.h>
int main (){
int i, num, soma, maior, menor;
float media;
printf ("Informe 10 valores:\n");
for (i=1; i<=10; i++){
scanf ("%d", &num);
if (i==0){
maior=num;
menor=num;
}
else{
if (num > maior){
maior=num;
}
if (num < menor){
menor=num;
}
}
soma = soma + num;
media = soma / 10;
}
printf ("Media: %.2f", media);
printf ("\nMaior: %d", maior);
printf ("\nMenor: %d", menor);
}
If my i start at 0 the number printed on the smallest is incorrect.
– Gustavo Carvalho
So there’s more... pera
– Jefferson Quesado
I don’t see anything yet that could be wrong beyond what I’ve already pointed out, I’ll need to put in ideone. Cc @Gustavocarvalho
– Jefferson Quesado
Before I was having problems because I was not showing the values in bigger and smaller were coming out as 0 but the average came out right, then I saw that they were in the float then I put them as int so that now the average goes wrong and the values and bigger and smaller comes out correct.
– Gustavo Carvalho
Failed to initialize
soma
, updating the response– Jefferson Quesado
how to initialize the sum?
– Gustavo Carvalho