Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

RESTRICTED USE LA TROBE UNIVERSITY CSE1PES/CSE5CES PRACTICE EXAM 2018 Reading Time: 15 minutes Writing Time: 120 minutes (Note: Actual CSE5CES 2018 exam is 150 minutes writing time with one extra...

1 answer below »
RESTRICTED USE

LA TROBE UNIVERSITY


CSE1PES/CSE5CES
PRACTICE
EXAM 2018
Reading Time: 15 minutes
Writing Time: 120 minutes
(Note: Actual CSE5CES 2018 exam is 150 minutes writing time with one
extra question. CSE1PES is 120 minutes writing time)








INSTRUCTIONS TO CANDIDATES

1. Total marks = 120
2. Answer all questions.
3. Write your answers in the space provided in the question paper after each question.
2 OVER/
Question 1 [15]

This question has 10 parts. Each part is a multiple choice question. Answer each multiple choice question by placing a
tick mark () in box opposite the co
ect (best) option.

1. What is the storage size of a char in bytes in C?
a) 4 
b) 8 
c) 2 
d) 1 
e) 32 


2. Which of the following is the hexadecimal representation of the binary number XXXXXXXXXX:
a) 0x8F 
b) 0x4A 
c) 0xA4 
d) 0x6E 
e) 0xA23 


3.
Is the following a
ay declaration and initialisation legal? If so, what is the value of myA
ay[4]?
int myA
ay[7] = {1,2,8,7};
a) It is not legal. 
b) It is legal. The value is 0 
c) It is legal. The value is 7 
d) The syntax is wrong. 
e) It is legal. The value is -1 


4. Which function do we use to release run-time storage?
a) destroy 
b) end 
c) free 
d) kill 
e) release 


3 OVER/
5. What is the data type of argc?
a) int A
ay XXXXXXXXXXint argc[]) 
b) int XXXXXXXXXXint argc) 
c) double XXXXXXXXXXdouble argc) 
d) char XXXXXXXXXXchar argc) 
e) pointer to an int (int* argc) 


6. What is the typical file extension for a header file?
a) .header 
b) .h 
c) .hd 
d) .c 
e) .obj 


7. What value will the following return?
XXXXXXXXXXstrncmp("granite", "granular", 4);

a) strncmp will not return a value. 
b) This is not a legal use of strncmp. 
c) 0 
d) A negative integer. 
e) A positive integer. 


8. Which of the following successfully scans the first string contained in the file pointed to by fptr into the
string inputBuff
a) fscanf(fptr, "%s", &inputBuff); 
b) fscanf(fptr, inputBuff); 
c) fscanf(fptr, "%s", inputBuff); 
d) inputBuff = scanf("%s", fptr); 
e) fscanf(fptr, %s, inputBuff); 


4 OVER
9. Which of the following expressions is equivalent to the expression below?
XXXXXXXXXXa * d + b / c * a + -d

a) (a * d) + ((b / c) * a) + (-d) 
b) (a * d) + ((b / c) * a) + d 
c) (b * d) + ((a / c) * a) + (-d) 
d) (a * d) + (b / c) * (a + (-d)) 
e) ((a * (d + b) / c) * a) + (-d) 


10 Which of the following successfully toggles bit 0 in the variable bitTest?
a) bitTest &= ~0x01; 
b) bitTest &= 0x00; 
c) bitTest &= ~0x00; 
d) bitTest |= ~0x00; 
e) bitTest ^= 0x01; 


5 OVER/
Question 2 [25]

This question has 10 parts. Answer each part in the space provided.

a) What is the output of the following C code fragment?
#include
int main()
{
int a = 5, b = 4, c;
c = a/2;
printf("The result is: %d\n", c);
return 0;
}
Answer:















) What is the output of the following C code fragment?
char bitTest = 0x00;
itTest &= ~0x02;
if((bitTest & 0x02)!=0x00)
{
XXXXXXXXXXprintf(“1\n”);
}
else
{
XXXXXXXXXXprintf(“2\n”);
}
Answer:


6 OVER/
c) What is the output of the following C code fragment?
int i = 3;
while(i > 0)
{
printf("%d... ", i);
--i;
}
printf("Go!!\n");
Answer:


















d) What is the output of the following C code fragment?
int result = 0, a = 7, b = 8, c = 7;
if((a < b || c == b) && !result)
{
result = a != c;
}
printf(“%d\n”, result);
Answer:



7 OVER/
e) Given that the user input is as follows:
25, -3.005
What is the output of the following C program?
#include

int main()
{
int a, b;
float c;
scanf("%d,%d%f", &a, &b, &c);
a = a / 2 + b;
c -= b;
printf("Result:%d, %.2f", a, c);
return 0;
}
Answer:











f) What is the output of the following C code fragment assuming the user input given below?
Input: BAbDAjCC
int num[4] = {0};
int count = 0;
while(count < 5)
{
char ch = getchar();
if(ch >= 'A' && ch <= 'D')
num[ch - 'A']++;
++count;
}
printf("%d %d %d %d", num[0], num[1], num[2], num[3]);
Answer:



8 OVER/

g) What is the output of the following C code fragment?
#include

void sum(int x, int y);
int main()
{
int num = 8;
sum(num, 2);
printf("%d", num);
return 0;
}
void sum(int x, int y)
{
x = x + y;
}
Answer:















h) What is the output of the following C code fragment?
#include

#define MACRO
int main()
{
int x = 5;
#ifdef MACRO
++x;
#endif
printf("%d", x);
}
Answer:



9 OVER/
i) What is the output of the following C code fragment?
char string1[15] = “The “;
char string2[11] = “Best Pizza”;
strcat(string1, string2);
printf(“%s %s\n”, string1, string2);
Answer:
















j) What is the output of the following C code fragment?
int a
[5] = {9, 11, 20, 8, 2};
int num = 6;
int *p = a
;
while(p < &a
[5])
{
if(*p > num)
{
XXXXXXXXXXnum = *p;
}
++p;
}
printf("%d", num);
Answer:




10 OVER/
Question 3 [21]

Consider the code given below:

1 #include
2
3 void exam_function(int e, int* f, float* g, float* h, int** i);
4 int** p;
5 int* q;
6
7 int main()
8 {
9 float x=7.8, y=4.2;
10 int z = 4;
11 q = &z;
12 p = &q;
13 exam_function(z, &z, &x, &y, p);
14
15 printf("x = %.3f, y = %.3f, z = %d\n", x, y, z);
16 return(0);
17 }
18
19 void exam_function(int e, int* f, float* g, float* h, int** i)
20 {
21 e=5+*f;
22 *g=*f+**i;
23 float* t = g;
24 g = h;
25 h = t;
26 *t = 8.667;
27 }


The lines of the code listed above have been numbered for reference.

In this question you have to describe the changes
Answered Same Day Jun 16, 2021 CSE5CES La Trobe University

Solution

Arun Shankar answered on Jun 18 2021
142 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here