rendered paste body#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <math.h>#include <string.h>void menu();void edit_shape();void add_shape();void rem_shape();void list_shape();void show_shape();typedef struct Shape { double dA; double dB; int name; struct Shape *next;};struct Shape * Shape_list;void show_shape(struct Shape *Shape){ if(Shape->name==1){ printf("Shape:Square\n"); } else{ if(Shape->name==2){ printf("Shape:Rectangle\n"); } else{ if(Shape->name==3){ printf("Shape:Circle\n"); } else{ if(Shape->name==4){ printf("Shape:Ellipse\n"); } else{ printf("This isn't right at all\n"); } } }} printf("The dimensions you entered were %f and %f\n", Shape->dA, Shape->dB); //printf("Area: %s\n", Shape->area); //printf("Perimeter: %d\n", Shape->perimeter);}void list_shape(){ struct Shape *exit = Shape_list; if (exit != 0) { while (exit != 0) { show_shape(exit); exit = exit->next; } } else { printf("No shapes in list\n"); }}void add_shape(){ int num=0; int s=0; struct Shape * alter = (struct Shape*) malloc(sizeof(struct Shape)); printf("Enter Shape Type\n"); printf("------------------------------\n"); printf("Press 1 to select Square\n"); printf("Press 2 to select Rectangle\n"); printf("Press 3 to select Circle\n"); printf("Press 4 to select Ellipse\n"); printf("Press 9 to exit to Menu\n"); printf("------------------------------\n"); scanf("%d",&num);if (num==1){ alter->name=1; printf("Enter a value for the side of the square\n"); scanf("%f",&s); if (s>0){ alter->dA=s; menu(); } else { printf("Invalid entry, please try again\n"); menu(); } }else { if (num==2){ alter->name=2; double l; double w; printf("Enter a value for the length of rectangle\n"); scanf("%f",l); printf("Enter a value for the width of rectangle\n"); scanf("%f",w); if (l<=0 || w<=0){ printf("Invalid entry, please try again\n"); menu(); } else { alter->dA=l; alter->dB=w; menu(); } } else { if(num==3){ alter->name=3; double r; printf("Enter a value for the radius of the circle\n"); scanf("%f",r); if (r<=0){ printf("Invalid entry, please try again\n"); menu(); } else { alter->dA=r; alter->dB=r; menu(); } } else { if(num==4){ alter->name=4; double a; double b; printf("Enter cross sectional length of ellipse\n"); scanf("%f",a); printf("Enter cross sectional height of ellipse\n"); scanf("%f",b); if (a<=0 || b<=0){ printf("Invalid entry, please try again\n"); menu(); } else { alter->dA=a; alter->dB=b; menu(); } } else { printf("Please try another number\n"); menu(); } } } } alter->next = Shape_list; Shape_list = alter;}void rem_shape(){ } void edit_shape(){ }void menu(){ struct Shape *alter; char exit = 0; Shape_list = 0; while (exit != 'X'){ printf("Menu\n"); printf("------------------------------\n"); printf("Press A to add shape\n"); printf("Press R to remove shape\n"); printf("Press E to edit shape\n"); printf("Press L to list shapes\n"); printf("Press X to exit\n"); printf("------------------------------\n"); printf("What would you like to do?\n"); exit = getc(stdin); getc(stdin); switch (exit) { case 'A': add_shape(); break; case 'R': rem_shape(); break; case 'E': edit_shape(); break; case 'L': list_shape(); break; case 'X': printf("The Program has been exited\n"); getc(stdin); break; default: printf("Invalid choice, please try again\n"); } } //Frees memoriesalter = Shape_list->next; while (Shape_list != 0) { free(Shape_list); Shape_list = alter; alter = alter->next; }}int main() { menu(); return 0;}