Posts

Showing posts from November, 2022

Stack Menu driven program

 /* C Program for stack operations using switch case*/ #include<stdio.h> #include<stdlib.h> #define MAX 10 int stack_arr[MAX]; int top = -1; void push(int item); int pop(); int peek(); int isEmpty(); int isFull(); void display(); int main() {         int choice,item;         while(1)         {                 printf("\n1.Push\n");                 printf("2.Pop\n");                 printf("3.Display the top element\n");                 printf("4.Display all stack elements\n");                 printf("5.Quit\n");                 printf("\nEnter your choice : ");                 scanf("%d",&choice);           ...

Queue Menu driven program

 /* Menu Driven C Program to implement queue using array */ #include<stdio.h> #include<stdlib.h> #define MAX 10 int queue_arr[MAX]; int rear=-1; int front=-1; void insert(int item); int del(); int peek(); void display(); int isFull(); int isEmpty(); int main() {         int choice,item;         while(1)         {                 printf("\n1.Insert\n");                 printf("2.Delete\n");                 printf("3.Display element at the front\n");                 printf("4.Display all elements of the queue\n");                 printf("5.Quit\n");                 printf("\nEnter your choice : ");                 scanf("%d",&choice);...

Singly linked list - menu driven

 // C program for the all operations in // the Singly Linked List #include <stdio.h> #include <stdlib.h> // Linked List Node struct node {     int info;     struct node* link; }; struct node* start = NULL;    // Function to create list with n nodes initially  void createList() {     if (start == NULL) {         int n;         printf("\nEnter the number of nodes: ");         scanf("%d", &n);         if (n != 0) {             int data;             struct node* newnode;             struct node* temp;             newnode = malloc(sizeof(struct node));             start = newnode;             temp = start;             printf("\nEnter number t...

doubly Linked list -Write a menu driven program to perform opration on Doibly linked list in c

// C program for the all operations in // the Doubly Linked List #include <stdio.h> #include <stdlib.h>   // Linked List Node struct node {     int info;     struct node *prev, *next; }; struct node* start = NULL;   // Function to traverse the linked list void traverse() {     // List is empty     if (start == NULL) {         printf("\nList is empty\n");         return;     }     // Else print the Data     struct node* temp;     temp = start;     while (temp != NULL) {         printf("Data = %d\n", temp->info);         temp = temp->next;     } }   // Function to insert at the front // of the linked list void insertAtFront() {     int data;     struct node* temp;     temp = (struct node*)malloc(sizeof(struct node));     printf("\nEnter num...

Array -Write menu driven program to perform opration on array in c

  #include <stdio.h> #include <stdlib.h> int a[20]; int n, val, i, pos; /*Function Prototype*/ void create(); void display(); void insert(); void Delete(); int main() {     int choice = 1;     while (choice)     {         printf("\n\n——–MENU———–\n");         printf("1.CREATE\n");         printf("2.DISPLAY\n");         printf("3.INSERT\n");         printf("4.DELETE\n");         printf("5.EXIT\n");         printf("———————–");         printf("\nENTER YOUR CHOICE:\t");         scanf("%d", &choice);         switch (choice)         {         case 1:             create();             break;         case 2:       ...