I have such an loop:

int i = 1230;
    while(i<1300){
       int k = 0;
       Flight removedItem = RemoveQ(&Item);
       if(removedItem.C_TIME <= 1230){
          k = k + 1;
          printf("%d", removedItem.C_TIME);  
       }       
       i = i + 5;
       printf("%d", removedItem.C_TIME);  // it prints correct values here
    }

Why the if statement does not work ?? I am sure the type of C_TIME is int...

how is RemoveQ declared? Does it actually return a Flight object or a pointer to one?

Post the Flight structure.

and what do you mean by "it doesn't work"? It doesn't compile? what are compile errors?

typedef Flight ItemType;
typedef int PosType;
typedef struct{
        ItemType Data[MAXSIZE];
        PosType Rear,Front;
        }QType;


ItemType RemoveQ(ItemType *Item)
{
     if (!EmptyQ())
     {
      *Item=Q.Data[Q.Front];
       printf("\n\nRemoving.%c",Q.Data[Q.Front].FL_NUM);
       
        Q.Data[Q.Front].C_TIME = 0;
        Q.Data[Q.Front].D_TIME = 0;
        Q.Data[Q.Front].FL_NUM = '?';
        Q.Data[Q.Front].D_CITY = '?';
       
       //Q.Data[Q.Front]='?';
       Q.Front=(Q.Front + 1 )%MAXSIZE;          
     }
     else 
        printf("\n\nQueue is empty");
     
      return Q.Data[Q.Front];
}

I mean that it complise but does not print anything because if statement does not work, please help...

I can't tell what's wrong. You need to use your debugger and put a break point on that if statement so that you can see the value of the variables. The probalem is most likely somewhere else, such as using uninitialized variables in those structures.

I have such an loop:

int i = 1230;
    while(i<1300){
       int k = 0;
       Flight removedItem = RemoveQ(&Item);
       if(removedItem.C_TIME <= 1230){
          k = k + 1;
          printf("%d", removedItem.C_TIME);  
       }       
       i = i + 5;
       printf("%d", removedItem.C_TIME);  // it prints correct values here
    }

Why the if statement does not work ?? I am sure the type of C_TIME is int...

In line 10, you said it prints the correct values, but does the correct values smaller than 1230?

@sivaslieko++ is it the 'if' not working or your logic is not working?

One unfortunate thing associated with computer is, it does not work the way you want it to work it works the way it should work!! :)
I am a victim !! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.