Please follow the instructions below to create a code. The instructions are broken down into a few steps.
Create the following functions along with a driver for each one confirming it works. The driver needs to test the function with at least 5 different inputs, although more is always better.
Be sure to use the function display_startup_banner( ) in all of your drivers.
Please create separate files for each code. That is, if you're creating a function called learning_online_is_a_trip( ) put it in a file called learning_online_is_a_trip.c and then compile it along with your driver.
Part 1 Using the function prototype
void print_all_integers( const int array[ ], const int elements, const char header[], const char tag[ ] );
create a function that displays the following
Displaying array sample1
sample1: [ 0 ] = 68
sample1: [ 1 ] = 94
sample1: [ 2 ] = 71
sample1: [ 3 ] = 60
4 elements displayed.
The string "Displaying array sample1" is passed in as header.
The sting "sample1" is passed in as tag.
Part 2 Write a function that takes an array of n integers and prompts the user to enter values for each of the elements.
Allow the user to end the program by entering a sentinel value passed in to the function when it is invoked.
Part 3 Write a function that takes an array of n integers and fills it with random numbers from x to y. For example, if I have an array of 4 integers and I want it filled with random numbers from 60 to 100, I might end up with the array shown.
Use the rand( ) function to generate the appropriate random numbers, and the srand( time( NULL ) ) function call to seed the random number generator.
Part 4 Using the following programmer-defined type definitions:
typedef enum { clubs, diamonds, hearts, spades } suit_t;
typedef enum { ace = 1, two, three, four, five, six, seven, eight, nine, ten, jack, queen, king } rank_t;
Write a function that accepts an array of five pairs of suit_t and rank_t values.
The function should return true if there are three matching suit_t values, or it should return true if there are three matching rank_t values, otherwise it should return false.
B)
#include <stdio.h>
#include <stdlib.h>
void print_all_integers( const int array[], const int elements, const char header[], const char tag[] ){
printf(header);
printf("\n");
for(int i=0;i<elements;i++){
printf("%s: [ %d ] = %d\n",tag,i,array[i]);
}
printf("%d elements displayed.",elements);
}
void input(int array[], int *n){
printf("Input Array values. (-1) to stop...\n");
int x=1;;
while(x!=-1){
printf("array: [ %d ] = ",*n);
scanf("%d",&x);
if(x==-1)
return;
array[(*n)++]=x;
}
}
int main(int argc, char const *argv[])
{
int array[100];
int elements=0;
input(array,&elements);
char tag[] = "array";
char header[] = "Displaying array";
print_all_integers(array,elements,header,tag);
return 0;
}
----------------------------------------------------------------------------------------------------
A)
![Displaying array samplel samplel: [ 0 ] = 68 samplel: [ 1 ] = 94 sample1: [ 2 ] = 71 sample1: [ 3 ] = 60 4 elements displayed](http://img.homeworklib.com/questions/004902b0-ac58-11eb-b5c1-47aad70b506b.png?x-oss-process=image/resize,w_560)
#include <stdio.h>
#include <stdlib.h>
void print_all_integers( const int array[], const int elements, const char header[], const char tag[] ){
printf(header);
printf("\n");
for(int i=0;i<elements;i++){
printf("%s: [ %d ] = %d\n",tag,i,array[i]);
}
printf("%d elements displayed.",elements);
}
int main(int argc, char const *argv[])
{
int array[] = {68,94,71,60};
int elements = 4;
char tag[] = "sample1";
char header[] = "Displaying array sample1";
print_all_integers(array,elements,header,tag);
return 0;
}
--------------------------------------------------------
C)
#include <stdio.h>
#include <stdlib.h>
void print_all_integers( const int array[], const int elements, const char header[], const char tag[] ){
printf(header);
printf("\n");
for(int i=0;i<elements;i++){
printf("%s: [ %d ] = %d\n",tag,i,array[i]);
}
printf("%d elements displayed.",elements);
}
void fill(int array[], int n,int x,int y){
printf("generating Random values...\n");
srand(time(NULL));
for(int i=0;i<n;i++)
array[i] = rand()%(y-x)+(x);
}
int main(int argc, char const *argv[])
{
int array[5];
int elements=5;
fill(array,elements,60,100);
char tag[] = "array";
char header[] = "Displaying array";
print_all_integers(array,elements,header,tag);
return 0;
}
Please follow the instructions below to create a code. The instructions are broken down into a...
Make sure to create the code with the given functions, and do not overlook them, do not create your own functions. This is an assignment that I did on my own and that's passed due, therefore, for educational purposes, I am interested to know what are other ways to properly program this. Please follow instructions as I am doing my best to fully understand every crucial detail in order to become a better programmer who is able to come up...
I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...
Please help with this coding 1.You need to dynamically allocate memory to read into a number of elements. At first, you need to determine how many numbers (here, ‘n’) to be read. Next, you need to dynamically allocate memory for ‘n’ integers. As you see,‘x’ is an integer pointer which needs to dynamically allocate memory to read ‘n’integers into it fromthekeyboard. 2 Read nintegers into the allocated block using scanf. 3. Complete the printArrayfunction to display ‘n’ integers. void printArray(int...
IN C++ ADD COMMENTS AS MUCH AS POSSIBLE Exercise 1: Duplicate the Arrays Suppose you are developing a program that works with arrays of integers, and you find that you frequently need to duplicate the arrays. Rather than rewriting the array-duplicating code each time you need it, you decide to write a function that accepts an array and its size as arguments. Creates a new array that is a copy of the argument array, and returns a pointer to the...
C++ no std: cout but cout<<" ". also nothing ".h": in the header files: Also if statements should be used for the file portion. (filein.eof is not aloud) generate integer random numbers and place them in a file. Each number on a single line. The numbers should range between 1-200 and the program should generate between 100-150 numbers. This means each time the program is executed, a file is created containing between 100-150 numbers with values between 1-200. Make sure...
Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...
in c++ please Assignment Instructions: MAIN FUNCTION: Ask the user how many students were surveyed. Call a function called makeArray to define an array of integers with the number of elements equal to the number of students surveyed. Call a function called getStudentData to allow the user to enter the number of hours each student spent watching Netflix into the array. Call a function called getAverage to calculate and display the average of the hours entered. Call a function called...
Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the size of an array. Then create an integer array of that exact size. Ask the user to enter a maximum value and then write a loop to fill the array with random numbers with value in the range of 1 to the maximum value. For example, if the maximum value is 100, random numbers must have value 1 to 100 inclusive. Input size of...
follow the instructions inside. You are to implement the sequential search of array elements. User will enter a value (size) which represents the number of values to process The values entered will be stored in an array of type short that has 1000 elements User will enter size numbers The user will enter a search value The program will search the data for a specific value program will display a message in which element the value was found or display...
In C++ please!
*Do not use any other library functions(like strlen) than the
one posted(<cstddef>) in the code below!*
/**
CS 150 C-Strings
Follow the instructions on your handout to complete the
requested function. You may not use ANY library functions
or include any headers, except for <cstddef> for
size_t.
*/
#include <cstddef> // size_t for sizes and indexes
///////////////// WRITE YOUR FUNCTION BELOW THIS LINE
///////////////////////
///////////////// WRITE YOUR FUNCTION ABOVE THIS LINE
///////////////////////
// These are OK after...