-1
at the end I still need to print which stores are presenting a price within the media, someone help me;
#include<bits/stdc++.h>
struct difsites{
double preco;
char loja[50];
char site[50];
};
int main(){
int i,j;
double soma, media;
struct difsites MP;
for(i=0;i<6;i++){
printf("Insira o nome da loja: ");
scanf(" %50[^\n]s", &MP.loja);
printf("Insira a URL: ");
scanf(" %50[^\n]s", &MP.site);
printf("Insira o valor do computador: ");
scanf(" %lf", &MP.preco);
soma+=MP.preco;
media=soma/6.0;
}
printf("Preco medio: R$%.2lf\n",media);
}
If you select the code and press
ctrl+k, it will be formatted cute as it is now. This makes it easier to read– Jefferson Quesado
To solve this problem, better start storing several "
difsites" to be able to access them later. You will only read them once, you can only average after reading all of them and, at the end, you need to compare each "difsites" with the average. This is a good indication that you need to store them for later access– Jefferson Quesado
Why the c++ tag? You are not using anything in the c program++.
– Isac