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

Creating, updating and displaying a list using a menu. Create an array called my

ID: 3851616 • Letter: C

Question

Creating, updating and displaying a list using a menu. Create an array called myList. Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList. Initialize the first 100 elements of myList by calling the FirstElements function. Create a menu to display the following options and a number corresponding to each option which is used for selecting the desired option: adding any amount of numbers to myList removing all occurrences of a selected number from myList finding and displaying the maximum, minimum and range (maximum-minimum) in myList finding the number of occurrences of a number in myList doubling (multiplying by 2) all numbers in myList display all members of myList. quit for each menu item create a function. when the item number is typed, the function should be executed, the required inputs should be requested, and the proper output should be produced. the outputs can be formatted in a proper fashion of your choice after executing any function in the menu, the user should be given the choice to select another menu or quit (Y for the new request and Q for quit). if the user has a new request, the menu should appear again and the process repeated.

Explanation / Answer

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

int i,s,max,min,j,count,k;

void removal(int arr[])

{

s = sizeof(arr[]);

printf(" Enter the number you want to delete :");

scanf("%d",&j);

for(i=0; i<s; i++)

{

if (arr[i]==j)

{

for(k=i;k<s;k++)

arr[k]=arr[k+1];

break;

}

}

printf(" successfully removed");

}

void insert(int arr[])

{

printf(" Enter the number you want to insert : ");

scanf("%d",&i);

s = sizeof(arr[]);

arr[s+1]=i;

printf(" %d successfully inserted",i);

}

void doubling(int arr[])

{

s = sizeof(arr[]);

for(i=0; i<s; i++)

arr[i]=arr[i]+arr[i];

printf(" successfully doubled");

}

void maxmin(int arr[])

{

s = sizeof(arr[]);

for(i=1; i<s; i++)

{

/* If current element of array is greater than max */

if(arr[i]>max)

{

max = arr[i];

}

/* If current element of array is smaller than min */

if(arr[i]<min)

{

min = arr[i];

}

}

printf(" Maximum is :%d minimum is : %d",max,min);

}

void occurance(int arr[])

{

s = sizeof(arr[]);

printf("Enter the number to find the occurance :")

scanf("%d",&j);

for(i=1; i<s; i++)

{

if(arr[i]=j)

count++;

}

printf(" total number of occurance :%d",count);

}

void disp(int arr[])

{

s = sizeof(arr[]);

for(i=1; i<s; i++)

printf(" %d",arr[i]);

}

void main()

{

int m=0;

int randarr[100],c;

randomize();

for (c = 1; c <= 100; c++)

  

randarr[c] = (rand()%(1000-100))+ 100;

clrscr();

printf(" OPERATIONS ON RANDOM NUMBERS USING ARRAY ");

do

{

printf(" MENU ");

printf(" 1.INSERT ");

printf(" 2.REMOVE ");

printf(" 3.MAXIMUM AND MINIMUM NUMBER");

printf(" 4.OCCURANCE ");

printf(" 5.DOUBLING");

printf(" 6.DISPLAY");

printf(" 7.QUIT ");

printf(" ENTER YOUR CHOICE : ";

scanf("%d",&m);

switch(m)

{

case 1: insert(randarr);

break;

case 2: removal(randarr);

break;

case 3: maxmin(randarr);

break;

case 4: occurance(randarr);

break;

case 5: doubling(randarr);

break;

case 6: disp(randarr);

break;

}

}while(m!=7);

}

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