-2
I’m trying to divide/multiply all the numbers between themselves using vectors.
for example: type 4 numbers and divide them all: 5/5/2/1 but I can’t get the division. follow the program:
float numeros[4];
float resultado;
float soma;
printf("digite 4 numeros: \n");
for(int i = 0; i < 4; i++) {
scanf("%f", &numeros[i]);
}
for(int i = 0; i < 4; i++) {
soma += numeros[i];
resultado = soma / numeros[i];
}
I didn’t understand very well what you want to calculate, even it doesn’t match the description, but you didn’t assign an initial value to the variable
soma
and so it’s leaving from memory junk.– anonimo
i want to divide more than one number at once. For example: the program asks for 3 numbers and divide them, type 4 / 3 / 2
– Marcelo Henrique
I don’t know if it’s possible that way, I wanted to know
– Marcelo Henrique
At the same time it is not possible, consecutively it is possible, first 4/3 after the result divided by 2 and so on. This can be done in the same operation
resultado = 4 / 3 / 2;
which is equivalent toresultado = (4 / 3) / 2;
. Not considering that you might be thinking of a program with different threads doing the divisions in parallel.– anonimo
got it. Thank you very much friend
– Marcelo Henrique