0
Hello
I’m putting together a code for an activity of my course but the media that needs to appear at the end if you enter a negative number only appears zero, I’m a beginner in programming so I’m not getting the notion that it might be wrong in the code, if anyone can give me some guidance as to what can be done to fix this problem would help quite.
thank you
#include<stdio.h>
#include<stdlib.h>
int main()
{
int c, cont, i, numero = 0, conta = 0;
float vetor[1000], media = 0, soma = 0;
cont = 0;
printf("Digite um numero:");
scanf_s("%d", &numero);
printf("\n");
while ((cont < 1000) && (numero >= 0))
{
vetor[cont] = numero;
printf("Digite um numero:");
scanf_s("%d", &numero);
cont++;
printf("\n");
}
if (numero < 0)
{
soma = cont++ + numero;
conta = soma / numero;
media = conta - numero <= 0;
}
printf("\n");
printf("A media dos numeros digitados e %d\n", &media);
printf("\n");
system("pause");
return 0;
}
This code you gave me worked, I tested it here.. but this one you gave me counts as a data vector? I saw that you didn’t use any vector to assemble the code..
– José Dutra
It doesn’t need vector. But because you were using a vector?
– Emerson Oliveira
this code is for an activity that I am doing, and in the statement asked me to type positive values and save the values in data vectors. That’s why I asked you about.
– José Dutra
So I get it. And you didn’t make it clear that you needed to store the numbers in a vector. If no one comments the code, with the vector you need I edit the post, until tomorrow afternoon, blz.
– Emerson Oliveira
is I forgot to specify, I’ll be trying here, if I can not enter here in the post again to see if someone has a solution to help me.
– José Dutra
I made the modification, if that’s what you needed, signal my post as the answer to your question for kindness. Thank you.
– Emerson Oliveira
it worked.. vlw by orientation, helped me a lot..
– José Dutra