Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList. using C program
#include<stdio.h>
#include<stdlib.h>
void FirstElements(int *array)
{
int i=0;
for(i=0;i<100;i++)
array[i]=100+rand()%(1000-100);
}
int Add(int *myList,int i)
{
int x=0;
printf("\nEnter the number to be
added : ");
scanf("%d",&x);
myList[i++]=x;
printf("\n");
return i;
}
int Delete(int *myList,int i)
{
int s=0,k=0,flag=0;
printf("\nEnter the number to be
deleted : ");
scanf("%d",&s);
for(k=0;k<i;k++)
{
if(myList[k]==s){
myList[k]=0;
flag=1;
}
}
if(flag==0)printf("\nNumber not found");
printf("\n");
printf("\n");
return i;
}
int MaxMin(int *myList,int i)
{
int min=0,max=0,k=0;
min=myList[0];
max=myList[0];
for(k=0;k<i;k++)
{
if(myList[k]>max) max=myList[k];
if(myList[k]<min) min=myList[k];
}
printf("\nMaximum=%d, Minimum=%d, Range=%d",max,min,max-min);
printf("\n");
return i;
}
int Search(int *myList,int i)
{
int k=0,s=0,flag=0;
printf("\nEnter the number to be
searched : ");
scanf("%d",&s);
for(k=0;k<i;k++)
{
if(myList[k]==s){
printf("\nNumber found at %d place in
myList",k+1);
flag=1;
}
}
if(flag==0)printf("\nNumber not found");
printf("\n\n");
return i;
}
int Double(int *myList,int i)
{
int k=0;
for(k=0;k<i;k++)
{
myList[k]=2*myList[k];
}
return i;
}
int Print(int *myList,int i)
{
int k=0;
printf("\nmyList is :\n");
for(k=0;k<i;k++)
{
printf("\nmyList[%d]=%d",k+1,myList[k]);
}
printf("\n");
return i;
}
int main()
{
int i=0,p=0;
int myList[10000]={0};
FirstElements(myList);
i=100;
char ch[2]={'Y','\0'};
while(p!=7)
{
printf("Press 1 to add number to
myList");
printf("\nPress 2 to remove all
occurences of a seleted number from myList");
printf("\nPress 3 to display
maximum, minimum and range in myList");
printf("\nPress 4 to find the
number of occurences of a number in myList");
printf("\nPress 5 to doubling all
the numbers in myList");
printf("\nPress 6 to display all
the members of myList");
printf("\nPress 7 to Quit");
printf("\nEnter your choice :
");
scanf("%d",&p);
if(p==1)
{
i=Add(myList,i);
}
else if(p==2)
{
i=Delete(myList,i);
}
else if(p==3)
{
i=MaxMin(myList,i);
}
else if(p==4)
{
i=Search(myList,i);
}
else if(p==5)
{
i=Double(myList,i);
}
else if(p==6)
{
i=Print(myList,i);
}
else if(p==7)
{
exit(1);
}
else if(p>=8 &&
p<1)
{
printf("\nWrong
Choice of p Entered");
}
printf("\nPress Y for new request
or Q to exit :");
scanf("%s",&ch);
while(ch[0]!='Y'){
if(ch[0]=='Q')
exit(1);
else if (ch[0]=='Y')break;
printf("\nPress Y for new request
or Q to exit :");
scanf("%s",&ch);
}
}
return 0;
}
Write a function called FirstElements for adding 100 random integers between 100 to 1000 to myList....
Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 - 1000. You will pass the array into functions that will perform operations on the array. Function 1: Create a function that will output all the integers in the array. (Make sure output is clearly formatted. Function 2: Create a Function that will sum and output all the odd numbers in the array. Function 3: Create a Function that will sum and output all the...
Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...
Please Help! Write a C++ program to read integers until 9999 is entered (called sentinel – sentinel is used to indicate the end of input and must not to be considered as the valid data for the computation). Perform the following operations for the integers entered by the user. Display the sum of the numbers less than 100 Display the smallest of the positive integers Display the largest of the negative integers Display how many integers are between 100 and...
using java
Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...
2. Write a C++ program, that generates a set of random integers and places them in an array. The number of values generated and their range are entered by the user. The program then continually prompts the user for one of the following character commands: a: display all the values I: display the values less than a given value g display the values greater than a given value e: display all odd values o: display all even values q: quit...
The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...
Derive a class called Stack from the linked list described in Assignment 2 (list of Dates). This means the Stack class will inherit all the properties (data and functions) of the linked list. But, since a stack only allows pushing and popping at the front of the list only, you will need to prevent the operations at the back. To do this, derive the Stack class in such a way that the base class (LinkedList) functions become private in the...
Python Program
Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...
Write a complete C++ program that will: Declare a vector of integers Use a pointer to dynamically allocate an array of 10 elements Ask the user how many values they would like to have in the data structures Read in the user’s response and make sure that it is greater than 20 (error loop) Generate the number of integers that the user asked for and store them into both data structures. The integer values should be unique unordered values (no...
Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++ required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....