QUEUE: If you are using this data structure then first entered data should be move out first.
STACK : If you are using this data structure then last entered data should be move out first.
Storage:
int arr[5] = {1, 2, 3, 4, 5};
/* Queue variable initialization */
int enqueueIndex = 0;
int dequeueIndex = 0;
/ * Queue operation logic */
enqueue (arr[enqueueIndex++], data1);
enqueue (arr[enqueueIndex++], data2);
enqueue (arr[enqueueIndex++], data3);
This time value of "enqueueIndex" is 3. If you want to remove element from queue then
while (dequeueIndex < enqueueIndex)
{
value = dequeue (arr[dequeueIndex++]);
}
/* Stack variable initialization */
int pushIndex = 0;
int popIndex = 0;
/* Stack operation logic *./
push (arr[pushIndex++], data1);
push (arr[pushIndex++], data2);
push (arr[pushIndex++], data3);
popIndex = pushIndex -1;
while (popIndex < = 0)
{
value = pop(arr[popIndex--]);
}