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

1. For each of the following parts, circle the letter corresponding to the corre

ID: 3639712 • Letter: 1

Question

1. For each of the following parts, circle the letter corresponding to the correct answer. (10)
(a) What value does the call strFunc1("PDS 2005") return?
int strFunc1 ( char A[] )
{
int i = 0;
while (A[i]) i = i + 1;
return i;
}
(A) 7 (B) 8 (C) 9 (D) ASCII value of 'P'
(b) What string does the following program print?
#include <stdio.h>
#include <string.h>
void strFunc2 ( char A[] , int n )
{
char t;
if (n <= 1) return;
t = A[0]; A[0] = A[n-1]; A[n-1] = t;
strFunc2(&A[1],n-2);
}
int main ()
{
char A[10] = "PDS 2005";
strFunc2(A,strlen(A));
printf("%s", A);
}
(A) 5002 SDP (B) 5DS 200P (C) PDS 2005 (D) SDP 2005
(c) What integer value is printed by the following program?
int main ()
{
int A[5] = {4,8,12,16,20}, *p;
p = A + A[0];
printf("%d", *p);
}
(A) 4 (B) 8 (C) 16 (D) 20
(d) What integer value is printed by the following program?
#include <stdio.h>
void what ( int *p )
{
*p = 10; p = p + 1;
}
int main ()
{
int A[5] = {4,8,12,16,20}, *p;
p = A;
what(p);
printf("%d", *p);
}
(A) 4 (B) 8 (C) 10 (D) 12
? Page

Explanation / Answer

(a) What value does the call strFunc1("PDS 2005") return? int strFunc1 ( char A[] ) { int i = 0; while (A[i]) i = i + 1; return i; } (A) 7 (B) 8 (C) 9 (D) ASCII value of 'P'