0
Good afternoon,
I am a beginner and I am creating a program with 3 vectors and I would like the entered value to demonstrate me on screen, but when running it shows some values that I did not type.
Could you help me:
#include<stdio.h>
#include<stdlib.h>
main()
{
int i, A[i], c[i], mult=0, ctrl;
char b[i];
char comb;
i=0;
A[i]=0;
c[i]=0;
ctrl=0;
printf("Quantos vendas foram realizadas? : ");
scanf("\n%d", &ctrl);
//Entrada de dados
for (i=0; i < ctrl; i++)
{
printf("Digite a quantidade em Litros: ");
scanf("\n%d", &A[i]);
printf("A[%d] = %d\n", i, A[i]);
printf("Digite o tipo do combustível: ");
scanf("\n%c", &b[i]);
printf("b[%d] = %c\n", i, b[i]);
printf("Digite o valor: ");
scanf("\n%d", &c[i]);
printf("c[%d] = %d\n", i, c[i]);
}
for (i=0; i < ctrl; i++)
{
mult = A[i] * c [i];
printf("i = %d valor multi: %d\n", i, mult);
}
//Imprimindo os valores do vetor
for (i=0; i < ctrl; i++)
{
printf("A[%d] = %d\n", i, A[i]);
printf("b[%d] = %c\n", i, b[i]);
printf("c[%d] = %d\n", i, c[i]);
}
}
You can say more what you want and what the problem is?
– Maniero
int i, A[i], c[i]
, what should be the size of the vector here?– Woss
You must indicate if you want to use static or dynamic memory, if it is static memory then just change I and put a value
A[50]
C[50]
because when we define a variable we have to allocate the memory, if it is by the static method as it is trying to do– Fábio Morais