After entering the Value of P, you are not running the printf of the second for

0
#define MAX 15
#define TAM 2
struct
{
    char m[MAX];
    int ano;
    float v;
} car[TAM];

int main(void)
{
    int i;
    int p;

    for(i=0; i<TAM; i++)
    {
        printf("Determine a Marca e Modelo do Carro %d: ", i+1);
        gets(car[i].m);
        printf("Determine o Ano do Carro %d: ", i+1);
        scanf("%d", &car[i].ano);
        printf("Determine o Valor do Carro1 %d: ", i+1);
        scanf("%f", &car[i].v);
        fflush(stdin);
    }

    printf("Determine o seu Orcamento: ");
    scanf("%f", &p);

    for(i<0; i<TAM; i++)
    {
        if(car[i].v<p)
        {
            printf("Marca: %s\nAno: %d\nPreco: %.2f", car[i].m, car[i].ano, car[i].v);
        }
    }
    return 0;
}
    
asked by anonymous 17.06.2018 / 05:48

2 answers

0

Look at this:

int p;
// ...
scanf("%f", &p);

I think what you wanted was this:

float p;
// ...
scanf("%f", &p);

That is, it was to use float instead of int .

Also, never use gets . In your other question , you already used fgets , use here too.

    
17.06.2018 / 07:22
-1

Hello, I also found these errors only:

  

The second one should look like this:

for(i = 0; i<TAM; i++) /*igual em vez de menor*/
  

You used P as float but declared as int

int p;

Colleagues have already mentioned this, here it is running correctly.

Hugs

    
17.06.2018 / 15:26