#include <stdio.h>
//declare our global variables
#define MAX 10
int numbers[MAX];
int head = 0;
int tail = -1;
//function to put new element into queue
void enqueue(int data) {
if(tail==MAX-1)
printf("The queue is full\n\n");
else {
tail++;
numbers[tail]=data;
}
}
//function to remove element from the queue
int dequeue() {
//declare our local variables
int temp;
if(tail==-1)
printf("The queue is empty\n\n");
else {
temp=numbers[head];
for (int i = 0; i < tail - 1; i++){
numbers[i] = numbers[i + 1];
}
tail--;
return temp;
}
}
int main() {
int evenCounter=0;
int oddCounter=0;
int i,number;
for(i=0;i<10;i++){
printf("Enter the number %d: ",(i+1));
scanf("%d",&number);
enqueue(number);
}
for(i=0;i<10;i++){
number=dequeue();
if(number%2==0){
evenCounter++;
}else{
oddCounter++;
}
}
printf("The total number of the even values: %d\n",evenCounter);
printf("The total number of the odd values: %d\n",oddCounter);
getchar();
getchar();
return 0;
}
Comments
Leave a comment