- 1

Implement queue in c program and implement sort function for queue elements in queue in descending any library function cannot

Use

9th Jul 2021, 4:28 PM
Narmadha.B
6 Antworten
+ 2
Any code you have written so far ?
9th Jul 2021, 4:43 PM
Abhay
Abhay - avatar
0
I write implement queue using arrays in c But how to sort a elements already in a queue is difficult to me
10th Jul 2021, 4:25 PM
Narmadha.B
0
Can you give me some solution
10th Jul 2021, 4:26 PM
Narmadha.B
0
#include<stdio.h> Int front=0,rear=-1; Int queue[]; Void insert(int); Void delete(); Void display(); Int main() { Int choice,value; While(1) { Printf(“Enter choice:”); Printf(“1.insert \n”); Printf(“2.Delete\n”) Printf(3.display\n”); Printf(4.Exit\n”); Scanf(“%d”,&choice); Switch(choice) { Case 1: Printf(“Enter a the value to insert:\n”); Scanf(“%d”,&value); Insert(value); Break; Case 2: Delete(); Break; Case 3: Display(); Break; Case 4: Return 0; Default: Printf(“Please enter correct choice\n”); } } }Void insert(int value) { If(Rear>=4) { Printf(“Queue is full\n”); Return ; } Rear++; Queue[rear]=value; } Void delete() { If(Rear==-1||front>rear) { Printf(“Queue is empty\n”); Front =0; Rear=-1; Return ; } Printf(“%d\n”,queue[front]); Front ++; } Void insert(int value) { If(Rear>=4) { Printf(“Queue is full\n”); Return ; } Rear++; Queue[rear]=value; } Void delete() { If(Rear==-1||front>rear) { Printf(“Queue is empty\n”); Front =0; Rear=-1;
10th Jul 2021, 4:30 PM
Narmadha.B
0
Rear=-1; Return ; } Printf(“%d\n”,queue[front]); Front ++; } Void display() nt; If(front>rear || rear==-1) { Printf(“queue is empty\n”); Return ; } While(temp!=(rear+1)) { Printf(“%d\n”,queue[temp]); Temp++; } }
10th Jul 2021, 4:32 PM
Narmadha.B
0
This is my code Can you please how to do a user defined function for sort a elements in descending order for an queue elements in c language
10th Jul 2021, 4:33 PM
Narmadha.B