Professional Documents
Culture Documents
OSEx 6
OSEx 6
#include <stdio.h>
#define MAX_SIZE 10
int buffer[MAX_SIZE];
int in = 0;
int out = 0;
int bufsize = 0;
void produce() {
int produce_value;
else {
scanf("%d", &produce_value);
buffer[in] = produce_value;
in = (in + 1) % MAX_SIZE;
bufsize++;
void consume() {
if (in == out)
else {
bufsize--;
int main() {
int choice = 0;
while (choice != 3) {
scanf("%d", &choice);
switch(choice) {
case 1:
produce();
break;
case 2:
consume();
break;
case 3:
break;
default:
return 0;
}
OUTPUT: