Read following C program, and answer question 6) to 7) int func( int arr[], int
ID: 3740640 • Letter: R
Question
Read following C program, and answer question 6) to 7)
int func( int arr[], int n)
{
int result = 0, i = 0;
for ( i = 0; i result ^= arr[i];
return result;
}
6) What value will be returned if the function call is func(arr,5) while the passed array has
elements 1,2,2,3 and 3 in it?
(a) 1
(b) 2
(c) 5
(d) None of above
7) What does the function func do?
(a) Get the first element from the array.
(b) Count the number of elements in the array.
(c) Remove pairs of elements with the same value from the array.
(d) None of above
8) Assume 'A' has a ASCII code 65, i is an int type variable and has a value 2, c is a
char type variable, so after the execution of c='A'+011, The value of c is:
(a) 'D'
(b) 68
(c) 'C'
(d) None of above
9) Which statement below is not equivalent to the other two (assuming that the loop bodies
are the same)?
(a) for(n=0; n<10; n++)
(b) for(n=0; n<10; ++n)
(c) for(n=1; n<=10; n=n+1)
(d) for(n=0; n++<10; )
10) Assume that a program contains the following declarations ?
char c=65;
int i=2;
double d = 5.5;
Give the date type of following expressions;
(1) (c+i)/d (2) d-c (3) c*I
(a) double, double, int
(b) int, double, int
(c) int, double, char
(d) None of above
Explanation / Answer
Your given example is syntactically incorrect so for both the questions 6 and 7 answers will be option d) None of the above.
If your code could have been like this
int func(int arr[],int n)
{
int result = 0, i = 0;
for ( i = 0; i<n ;i++)
result ^= arr[i];
return result;
}
Then the answer will be option a) for question 6 and option C) for question 7
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.