
Explanation of Solution
a)
Function using Pointers:
The following program demonstrates to take an integer array and adds all elements of the array.
Program:
//Select header files
#include <stdio.h>
#include<iostream>
using namespace std;
//Main function
int main()
{
//Integer array declaration
static int array[5] = { 200, 400, 600, 800, 1000 };
//Declaration of variables
int sum;
//Function for addition
int addnum(int *ptr);
// Store values into variable
sum = addnum(array);
//Display result
cout<< "Sum of all array elements ="<<sum<<"\n";
return 0;
}
Create the function “addnum()” which is used to add integers given in an integer array...
Explanation of Solution
b)
This program takes an integer array and removes all odd elements of array and displays only even elements of the array, the complete program code is shown below:
Program:
//Select header files
#include <iostream>
using namespace std;
//Declare the integer array with values
int ordArray[10] = {21,22,23,24,25,26,27,28,29,30};
int ordArray1[10];
In this construct, a pointer is declared which points to the given integer array. The function declaration is provided and values obtained are been pointed by an integer pointer and finally contents of array is been displayed.
//Main function
int main()
{
//Pointer to ordered array is created
int* ordArrayPtr = ordArray;
Declare the function “removeodd()” to remove odd numbers is been provided and then the values returned by the function are been pointed by an integer pointer
// Function to remove odd numbers
int* removeOddd(int* ordArrayPtr);
// Store the value in integer pointer
int* abc = removeOddd(ordArrayPtr);
Execute for loop to display the integer values present in the array which denotes the final result.
/*Display array values through for loop and loop until “j” value is less than 5*/
for ( int j=0; j < 5; j++ )
cout << *(abc + j) << endl;
//Console window is kept alive after the execution
cin.get();
return 0;
}
This function takes an integer array and removes all odd numbers from the array and displays only even numbers present in the array. It checks for each element in the array by iterating over array using loop and it displays the value only if it is an even number...
Explanation of Solution
Reason:
In the above case, it would be

Trending nowThis is a popular solution!

Chapter 1 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
- # Find the error:# The following code creates an empty dictionary and attempts to add a record# Why will the following code not create a new dictionary entry as intended?phoneBook = {}phoneBook{'Jobs, Steve'} = '999-111-1111'arrow_forwardSelect all the possible polar representations of the vector that is obtained from rotating where by Zrot Ź x = 3e² T= 3п 8 Hint: Consider the negative angle that is equivalent to the positive angle of the rotated vector. 0arrow_forwardCharacter Analysis If you have downloaded the source code you will find a file named text.txt on the Chapter 08 folder. Write a program that reads the file's contents and determines the following: The number of uppercase letters in the file The number of lowercase letter in the file The number of digits in the file The number of whitespace characters in the filearrow_forward
- Write a program that reads the text file's contents and calculates and outputs the following in this order: • The number of words in the file • The number of lines in the file • The number of uppercase letters in the file • The number of lowercase letters in the file • The number of digits in the file • The number of letter H's in the file • The number of whitespace characters in the file NOTE: Your program should include at least one try-except error handling statement block. Your program should also validate any input that could cause your program to crash. I'm Henery The Eighth, I Am! Henery The Eighth, I Am, I am!I got married to the widow next door,She's been married seven times before.And ev'ryone was a Henery,She wouldn't have Willie or a Sam.I'm her eighth old man named Henery,Henery the Eighth, I Am!Second verse same as the first!I'm Henery The Eighth, I Am! Henery The Eighth, I Am, I am!I got married to the widow next door,She's been married seven times before.And…arrow_forwardFigure 4-40 Modern Database Management, 13th edition, question 4-53arrow_forwardWhich of the following needs improvement in the dashboard shown? A. Instructional clarity missing for the views B. Filter placed at the top of the dashboard C. Inconsistent use of colors to represent missed goals D. Dashboard title too largearrow_forward
- If we click Show dashboard title in this dashboard, what will the title be?arrow_forwardPlease draw the diagram where it is asked to be drawn. Don't just describe how to do it.arrow_forwardC. Homework Assignment Task: Write a one-page CV using the provided template. Steps: 1. Use the CV guide to structure your CV. 2. Fill in each section with real information about yourself. 3. Format your CV neatly and use professional language. 4. Submit to the instructor before the next classarrow_forward
- Simulate on a vertical time axis (with events labeled with the senders names A-D) the contention period of FOUR equally distanced Ethernet stations that all attempt to transmit at T=0 a minimally sized frame, in the style of the binary Exponential Backoff Algorithm. Assume that time is measured in slot times, and that exactly one slot time is needed to detect a collision (so that if two stations transmit at T=1 and collide, and one of them chooses a backoff time k=0, then that station will transmit again at T=2). Use as coin flip (source of randomness) an ID written in binary. use the bits in order from the least significant to the most significant. If for a given coin throw you need k bits, use the least significant ID bit extracted in the corresponding group of bits, as the least significant bit of the coin thrown. Start be writing the ID, which is 904012207 As example of the expected answer format, with the random sequence R: 100101010101001011001010 01 01011 10010 1010 1010 010…arrow_forwardBig State University The Big State University course catalog reads as follows: "To enroll in MIS 260, which is an advanced course, a student must complete two prerequisites: MIS 120 and MIS 222. A student who completes either one of these prerequisites and obtains the instructor's permission, however, will be allowed to take MIS 260." Tasks 1. Create a decision table that describes the Big State University course catalog regarding eligibility for MIS 260. Show all possible rules. 2. Simplify the table you just created. Describe the results. 3. Draw a simplified decision tree to represent the Big State University catalog. Describe the results. 4. Why might you use a decision tree rather than a decision table?arrow_forwardWhat is the ALU result if the 4-bit ALU Control signal is 0100? What happens if the ALU Control signal is 0101?arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning




