Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Technical Interview Questions

Visual Basic Interview Question
ASP .NET Interview Questions
C++ Interview Questions
C Interview Questions

Programming Source Codes
C/C++ Source Codes
C# Source Codes

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions

C Tutorial
C++ Tutorial

Soft Skills
Communication Skills
Leadership Skills




C/C++ Source Codes

programme on implementation on queue

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Queue{
struct Queue *node;
char item[1];
struct Queue *volatile q;
int QueueAdd(const char *_item)
int _q;
struct Queue *queue;
_q = sizeof(struct Queue) + strlen(_item) + 4;
queue = (struct Queue *)malloc(_q); /* allocate the space in memory we need */
if (queue == 0) return 1;
memset(queue, 0, _q);
strcpy(queue->item, _item);
queue->node = q;
q = queue;

return 0;
void printq()
struct Queue *qq;

int n,j,num;
for (qq=q, num=0; qq; qq=qq->node, num++); /* enumerate items in queue */
printf("No items currently in the Queue");
printf("Here are the items in the Queue \n");
for (j=0,qq=q; (j < n) && qq; qq=qq->node, j++); /* lets hop to the next node */
printf("%s \n",qq->item);
goto cycle;
int main()
struct Queue *qq;
int i,num;
char in[100]; /* array of 100 bytes */
/* print to stdout */
printf("Welcome to the Queue!");
printf("\n Dequeue not implemented \n");
printf("Usage: \n");
input: /* input label */
printf("\n1. Add to the queue\n");
printf("2. Print number of items in Queue \n");
printf("3. Print the items in the Queue \n");
printf("4. Exit the program \n");

scanf("%d",&i); /* check for inputted data */
case 1:
printf("Enter Item to add to the Queue \n");

QueueAdd(in); /* call 'QueueAdd', let us assume everything goes o.k. */
printf("%s successfully added to the queue",in);
goto input;
case 2:
for (qq=q, num=0; qq; qq=qq->node, num++);
/* Null statement above to enumerate items in the queue */
printf("There are %d items in the queue",num);
goto input;
case 3:
goto input;
case 4:
printf("Exiting program");
break; /* why not? :) */

printf("Tu esta estupido!");
goto input;

<<<----- Return to C/C++ Source Code Questions Page.

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Object Oriented Interview Questions for more Object Oriented Interview Questions with answers

Check Data Structure Interview Questions for more data structure interview questions with answers