You are to write a function ( SumIt ) that receives three (3) parameters: an int
ID: 3540182 • Letter: Y
Question
You are to write a function (SumIt) that receives three (3) parameters: an integer array and the size of the array. The function will return the sum through the function name and the average through a third parameter passed in.
Write the statements to call the function SumIt, given the following:
int tobe[100], arySize, sum, avg;
Write the prototype for the function SumIt.
In the function SumIt, how is the array parameter passed?
In the function SumIt, how is the arySize parameter passed?
In the function SumIt, how is the third parameter (avg) passed?
You are giving the following input data for the code below:
10, 5b7.6,23 %u2026..input data where the b/// represents a blank
int n1, n2; float n3;
char k1, k2, k3;
%u2026.
cin >> n1;
cin >> k1 >> k2;
cin >> n2;
cin.get(k3);
cout << n1 << %u201C %u201C << n2 << %u201C %u201C << k1 << %u201C %u201C << k2 << %u201C %u201C << k3 << endl;
What prints out for the above?
I need to do a simulation for a local manufacturing company. I need an array that will hold 100 values per row with 25 rows. The array is to be initialized to random values between 10 and 40.Write the code to define an array as described above.
Write the code to fill the array with the values as described above.
You are given the following declaration.
class OneTwo
{ public:
int val
OneTwo * link;
};
OneTwo *head, *c, *p;
In general what data structure are we defining for OneTwo? (the answer is not a class or struct)
Write the code to print out all the values in the structure above. Assume data has been added to the data structure and head is the beginning.
Given the following code below, add to the code below that will put the new value read in (value) at the end of the data structure above.
int value;
cin >> value;
In a link list, what do we call the entities that are linked together? (generic term)
What is unique about the %u201Chead%u201D variable in the previous question?
You are given the following arrays n[20] and ans[20] and there is a 19 digit number stored in the array n, one digit per array location, right hand justified and in binary (not character form). Write the code to multiply the 19 digit number by 8 (a single digit number) and put the answer in ans, one digit per location. Define any other variables you need.
In programming we have a feature called Recursion.
List the three characteristic you must have to develop a recursive function.
Given the following code, what will print out?
int Woe( int n)
{ if ( n==0 )
return 0;
else
return 1 + Woe( n / 10);
}
int main()
{ int i;
int d = 84132;
cout << Woe(d) << endl;
}
Given any value (ex 4 or 82929 or 877 or 0) for the variable %u2018d%u2019 in Woe(d) above, what wie above routine print out? (In general, what does the above function compute?)
Explanation / Answer
You are to write a function (SumIt) that receives three (3) parameters:
an integer array and the size of the array.
The function will return the sum through the function name and the average through a third parameter passed in.
int SumIt(int a[], int k, int& avg)
{
int sum = 0;
for(int i=0; i<k; i++)
sum =sum+a[i];
avg = sum/k;
return sum;
}
Write the statements to call the function SumIt, given the following: int tobe[100], arySize, sum, avg;
sum = SumIt(tobe, arySize,avg);
Write the prototype for the function SumIt.
int SumIt(int a[], int k, int& avg);
In the function SumIt, how is the array parameter passed?
array parameter passed as address of first element of that array. (paas by reference)
In the function SumIt, how is the arySizeparameter passed?
arySizeparameter passed as pass by value;
In the function SumIt, how is the third parameter (avg) passed?
arySizeparameter passed as pass by reference;
You are giving the following input data for the code below:
10, 5b7.6,23 %u2026..input data where the b/// represents a blank
int n1, n2; float n3;
char k1, k2, k3;
cin >> n1;
cin >> k1 >> k2;
cin >> n2;
cin.get(k3);
cout << n1 << " " << n2 << " " << k1 << " " << k2 << " " << k3 << endl;
What prints out for the above?
10 4197808 5 7
I need to do a simulation for a local manufacturing company.
I need an array that will hold 100 values per row with 25 rows.
The array is to be initialized to random values between 10 and 40.
Write the code to define an array as described above.
int array[25][100];
Write the code to fill the array with the values as described above.
for(int i=0; i<25; i++)
for(int j=0; j<100; j++)
array[i][j] = 10 + rand()%30;
You are given the following declaration.
class OneTwo
{ public:
int val;
OneTwo * link;
};
OneTwo *head, *c, *p;
In general what data structure are we defining for OneTwo? (the answer is not a class or struct)
single linked list;
Write the code to print out all the values in the structure above. Assume data has been added to the data structure and head is the beginning.
OneTwo* ptr = head;
while(ptr!=null)
{
cout << ptr->val << endl;
ptr = ptr->link;
}
Given the following code below, add to the code below that will put the new value read in (value) at the end of the data structure above.
int value;
cin >> value;
OneTwo* new_node = new OneTwo();
new_node->val = value;
OneTwo* node_now;
if(head == null)
{
head = new_node;
node_now = new_node;
}
else
{
OneTwo* temp = head;
while(temp->next!=null)
temp = temp->next;
temp->next= new_node;
}
In a link list, what do we call the entities that are linked together? (generic term)
What is unique about the "head" variable in the previous question?
head represents the start of linked list.
You are given the following arrays n[20] and ans[20] and there is a 19 digit number stored in the array n,
one digit per array location, right hand justified and in binary (not character form).
Write the code to multiply the 19 digit number by 8 (a single digit number) and put the answer in ans,
one digit per location. Define any other variables you need.
In programming we have a feature called Recursion.
List the three characteristic you must have to develop a recursive function.
Given the following code, what will print out?
int Woe( int n)
{ if ( n==0 )
return 0;
else
return 1 + Woe( n / 10);
}
int main()
{ int i;
int d = 84132;
cout << Woe(d) << endl;
}
ans is 5.
Given any value (ex 4 or 82929 or 877 or 0) for the variable %u2018d%u2019 in Woe(d) above, what wie above routine print out?
(In general, what does the above function compute?)
no of bits in given integer d.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.