# FINAL EXAM REVIEW Jeopardy

FINAL EXAM REVIEW!!
Lets play C-eopardy!!!
Feel free to hum along!
Arrays
Functions
&amp;
Macros
Strings
Pointers
Loops
100
100
100
100
100
200
200
200
200
200
300
300
300
300
300
Question:
Given the following:
function prototype: void my_func(int array[][3]);
variable declaration: int X[2][3];
Which function call can you use to pass a 2dimensional array to a function?
1. my_func(X);
2. my_func(&amp;X[0][0]);
3. my_func(X[0]);
All of them
Question
What is printed:
int a[3][3]={0}, i,j;
for(i=0;i&lt;3;i++)
for(j=i;j&lt;3;j++)
a[i][j]=i*j;
for(i=0;i&lt;3;i++)
printf(“%d\t”,a[i][1]);
0
1
0
Question
What is printed:
int a[10]={0}, n=27212, abc;
while(n&gt;0)
{
abc=n%10;
if(a[abc])
{
printf(“%d\t”,abc);
break;
}
a[abc]=1;
n/=10;
}
2
Question
Given the following:
#define DOUBLE(x) (2*x)
What is the output for
printf(“%d”,DOUBLE(1+2));
4
Question
Write the following equation as a C statement
using functions from the math.h library.
y=(en ln(b))2
y=pow(exp(n*log(b)),2);
Question
Given the following program:
main()
{
int n = 10;
printf(“%d”,funct1(n));
}
int funct1(int n)
{
if(n&gt;0) return(n + funct1(n-1));
}
What is the o/p ?
55
Question
Given the following program:
#include &lt;stdio.h&gt;
#define ROWS 3
#define COLUMNS 4
int z[ROWS][COLUMNS] = {1,2,3,4,5,6,7,8,9,10,11,12};
int main()
{
int a, b, c;
for(a=0;a&lt;ROWS,++a) {
c = 999;
for(b=0;b&lt;COLUMNS;++b)
if(z[a][b] &lt; c) c = z[a][b];
printf(“%d ”,c);
}
What is the o/p?
159
(smallest value within each row)
Question
What is the output of the following code fragment:
int i;
char x[80] = “gorilla”;
char y[80] = “giraffe”;
char z[3][80];
strcpy(z[0],y);
strcpy(z[1],strcat(x,y));
strcpy(z[2],x);
for(i=0;i&lt;3;i++)
printf(“%s\n”,z[i]);
giraffe
gorillagiraffe
gorillagiraffe
Question
What is the final value of string s1?
strcpy(s1,&quot;computer&quot;);
strcpy(s2,&quot;science&quot;);
if(strcmp(s1,s2) &lt; 0)
strcat(s1,s2);
else
strcat(s2,s1);
s1[strlen(s1)-6] = '\0';
computers
Question
If ‘i’ is a variable and ‘p’ points to ‘i’, which of the
following expression are aliases for ‘i’ ?
a)
b)
c)
d)
*p
&amp;p
*&amp;p
&amp;*p
e)
f)
g)
h)
*i
&amp;i
*&amp;i
&amp;*i
a) g)
Question
Consider following declaration:
float table[2][3] = {
{1.1, 1.2, 1.3},
{2.1, 2.2, 2.3}
};
What is the value of ?
*(*(table+1));
2.1
Question
Given:
int x[]={-1,-2,-3,-4}, *px, **ppx;
px=x; ppx=&amp;px;
Which command will display -3.
A: printf(“%d”,**ppx+2);
B: printf(“%d”,*(*ppx+2));
C: printf(“%d”,*ppx+2);
D: printf(“%d”,*(ppx+2));
B
Question
Given the following:
int i=0,n=465;
do
{
n/=10;
i++;
}
while(n&gt;0);
printf(“i=%d\n”,i);
What is printed?
3
Question
What is printed:
int i=10;
while(i-- +2);
printf(“%d”,i);
-3
Question
What is displayed by the following code:
#include &lt;stdio.h&gt;
main()
{
int i,j,x=0;
for (i=0; i&lt;5; ++i) {
for(j=0;j&lt;i;++j)
x += (i+j-1);
printf(“%d”, x);
break;
}
printf(“\nx = %d”,x);
}
0
x=0
Arrays
Functions
&amp;
Macros
Strings
Pointers
Loops
100
100
100
100
100
200
200
200
200
200
300
300
300
300
300