Step #4) Call the function in step 1 to print 6 elements starting at element 12. Step #5) Write a swap function that will swap two integer parameters that are passed in by reference. Step #6) Use the swap function to swap the elements in the 100 element array at element 0 and 5. Display the first 8 elements in the array (using the function in step 1)
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
**ATTENTION: Step #1, #2, and #3 were already solved since I posted this same passage earlier. The following is the original prompt and after that you will find the answers to Step #1, #2, and #3 that someone already solved. Step #4, #5, #6 is what remains**
---------------------------------------------------------------------------------
C++ and the focus is on Pass by Reference:
The following steps are essentially under the same problem but in order to complete a step, the previous must be completed first. For example, Step #3 cannot be completed unless Step #1 has been conducted.
Step #1: Create a function to output the values of an integer array. You will have two parameters: the array and the number of elements to display.
Step #2: Create an array of integers of 100 elements. File the array with the values 1 to 100
Step #3: Call the function in step 1 to print 6 elements starting at element 0
Step #4) Call the function in step 1 to print 6 elements starting at element 12.
Step #5) Write a swap function that will swap two integer parameters that are passed in by reference.
Step #6) Use the swap function to swap the elements in the 100 element array at element 0 and 5. Display the first 8 elements in the array (using the function in step 1)
---------------------------------------------------------------------------------
** BELOW ARE THE ANSWERS TO STEPS #1, #2, #3**
Solution Step#1: Since the function is used to output (print) the array elements, therefore, its return type is void (no return value)
void arrayDisplay(int A[ ], int size)
{
for(int i=0; i<size; i++)
cout<<A[i];
}
Solution Step#2: An array is a group of elements of same datatype using same name but different index number. The index of first element is 0 and last element is size-1. An array with 100 elements can be declared as:
int Array[100]; // here Array is an identifier name, common for all elements
for( int i=0; i<100; i++)
Array[i]=i+1; // fill array with 1-100
Solution Step#3: In function call, only array name is pass with size also.
arrayDisplay(Array,6);
Step by step
Solved in 5 steps