Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

im not a greedy person so i will rate people for any number ofquestions that you

ID: 3609887 • Letter: I

Question

im not a greedy person so i will rate people for any number ofquestions that you answer. im not expecting all of them to beanswer just answer the ones you can. pluz a few of them i willprovide what i have and tell you what error im getting on it.

QUESTIONS 2,4,8 ARE ALREADY ANSWER!!!


1. Write a sequence of statements that finds the firstcomma in the string line , and assigns to the variable clause the portion of line up to, but not including thecomma. You may assume that an int variable pos , as well asthe variables line and clause , have already beendeclared.

2.
We informally define the term "corresponding element" asfollows: The first element in an array and the last element of thearray are corresponding elements. Similarly, the second element andthe element just before the last element are correspondingelements. The third element and the element just before the elementjust before the last element are corresponding elements -- and soon.


Given an array a and a variable n that containsthe number of elements in a , write an expression for thecorresponding element of a[i] .


3. Given the string variable address , write an expressionthat returns the position of the first occurrence of the string"Avenue" in address .

MY ANSWER: address.    ("Avenue")  
(HINT:missing something between the period and parenthesis)
ERROR : Remember what function to use to find a substring in astring. its not subtr or str

4.Reversing the elements of an array involves swapping thecorresponding elements of the array: the first with the last, thesecond with the next to the last, and so on, all the way to themiddle of the array.


Given an array a , an int variable ncontaining the number of elements in a , and two other int variables, k and temp , write a loop that reversesthe elements of the array.


Do not use any other variables besides a , n, k , and temp .

MY ANSWER:for (temp=n;temp>0; temp--;)

{

for (k=0; k<n;k++)

a[k] = a[temp-1];

}
ERROR: not given but wrong.



5.
You are given an int variable k , an intarray zipcodeList that has been declared and initialized,an int variable nZips that contains the number ofelements in zipcodeList , and a bool variable duplicates .


Write some code that assigns true to duplicates ifthere are two adjacent elements in the array that have the samevalue, and that assigns false to duplicates otherwise.

Use only k , zipcodeList , nZips ,and duplicates .


MY ANSWER:for(j=0;j<(nZips - 1) && !duplicates;j++)
{
for(k=j + 1;k<nZips && !duplicates;k++)
{
if(zipcodeList[j]==zipcodeList[k])
{
duplicates=true;
}
}
}
ERROR MESSAGE:   Unexpected identifiers: j

6.
Given:
an int variable k ,
an int array currentMembers that has beendeclared and initialized,
an int variable nMembers that contains the numberof elements in the array,
an int variable memberID that has beeninitialized, and
a bool variable isAMember ,


Write code that assigns true to isAMember if the valueof memberID can be found in currentMembers , and thatassigns false to isAMember otherwise.

Use only k , currentMembers , nMembers ,and isAMember .

MY ANSWER:
=;for (k = 0; k < nMembers; k++)
{(currentMembers[k] == memberID)
        isAMember =;
}


(hint: missing something before the equal sign, after the equalsign and also missing something after the last equal sign )
ERROR: not given.

7. Write the definition of a function max that hasthree int parameters and returns the largest.

MY ANSWER:max;
{
int min;
min = x;
if ( y < min) min = y;
if ( z < min) min= z;

return min;
}
ERROR: Function headers require parentheses.

8. Given the integer variables x and y , write afragment of code that assigns the larger of x and y toanother integer variable max .
MY ANSWER: max=0
if ( x <y){ max==y;} else if (y>x){max==x;}

ERROR: not given

Explanation / Answer

please rate - thanks my answers in red 2. We informally define the term "corresponding element" asfollows: The first element in an array and the last element of thearray are corresponding elements. Similarly, the second element andthe element just before the last element are correspondingelements. The third element and the element just before the elementjust before the last element are corresponding elements -- and soon. Given an array a and a variable n that containsthe number of elements in a , write an expression for thecorresponding element of a[i] . a[i] corresponding element a[n-i-1] if n=7 i=0       corresponding  6    1                             5 4.Reversing the elements of an array involves swapping thecorresponding elements of the array: the first with the last, thesecond with the next to the last, and so on, all the way to themiddle of the array. Given an array a , an int variable ncontaining the number of elements in a , and two other int variables, k and temp , write a loop that reversesthe elements of the array. Do not use any other variables besides a , n, k , and temp . for(k=0;k0; temp--;) { for (k=0; ky)      max=x; else      max=y;