Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a C program I already did the first one question 1 all i need is help wi

ID: 3803312 • Letter: T

Question

This is a C program

I already did the first one question 1 all i need is help with question 2 i dont know how to do it. Can you please type it and paste it here.

1.) Create a loop which genrates numbers between 1879 and 9987 and detect whether it is aprime number or not,and then insert it in a linked list and then implement the following functions

   a.) push b.) pop c).dequeue d.)displayinreverse e.)search(return the index of the location)

2.) Create a linked list with all the courses((CSIS1000,CSIS1020,CSIS1040,CSIS1050,CSIS2030,CSIS2050,CSIS2060,CSIS2065,FIT1012,FIT 1014,ITEC1020,ENG1030,ENG1020,ENG1021,MATH1020,MATH2020,PHY1011,PHY1015) and implement all the functions which I have given in the previous question(Make sure this name is on the list) Amad

Explanation / Answer

#include #include struct node { int info; struct node *ptr; } *top; *top1; *temp; int topelement(); void push(int data); void pop(); void empty(); void display(); void destroy(); void stack_count(); void create(); int count = 0; void main() { int no, ch, e; printf(" 1 - Push"); printf(" 2 - Pop"); printf(" 3 - Top"); printf(" 4 - Empty"); printf(" 5 - Exit"); printf(" 6 - Dipslay"); printf(" 7 - Stack Count"); printf(" 8 - Destroy stack"); create(); while (1) { printf(" Enter choice : "); scanf("%d", &ch); switch (ch) { case 1: printf("Enter data : "); scanf("%d", &no); push(no); break; case 2: pop(); break; case 3: if (top == NULL) printf("No elements in stack"); else { e = topelement(); printf(" Top element : %d", e); } break; case 4: empty(); break; case 5: exit(0); case 6: display(); break; case 7: stack_count(); break; case 8: destroy(); break; default : printf(" Wrong choice, Please enter correct choice "); break; } } } void create() { top = NULL; } void stack_count() { printf(" No. of elements in stack : %d", count); } void push(int data) { if (top == NULL) { top =(struct node *)malloc(1*sizeof(struct node)); top->ptr = NULL; top->info = data; } else { temp =(struct node *)malloc(1*sizeof(struct node)); temp->ptr = top; temp->info = data; top = temp; } count++; } void display() { top1 = top; if (top1 == NULL) { printf("Stack is empty"); return; } while (top1 != NULL) { printf("%d ", top1->info); top1 = top1->ptr; } } void pop() { top1 = top; if (top1 == NULL) { printf(" Error : Trying to pop from empty stack"); return; } else top1 = top1->ptr; printf(" Popped value : %d", top->info); free(top); top = top1; count--; } int topelement() { return(top->info); } void empty() { if (top == NULL) printf(" Stack is empty"); else printf(" Stack is not empty with %d elements", count); } void destroy() { top1 = top; while (top1 != NULL) { top1 = top->ptr; free(top); top = top1; top1 = top1->ptr; } free(top1); top = NULL; printf(" All stack elements destroyed"); count = 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote