Professional Documents
Culture Documents
ESC112A Quiz-2
ESC112A Quiz-2
Name ..................................
Jan 10, 2023
Duration 30 Minutes
Max Marks: 15 Roll no. ..................................
Instructions
1. The exam is closed book and closed notes. Use of mobile phones or access to
internet is not allowed.
2. This quiz paper has two sheets or four pages. There are a total of three questions.
3. Write your name, roll no. and section on both this and the third page top, in the
spaces provided.
4. Write your nal answers neatly in the space provided, strike out any rough work.
Space for rough work is provided at the end of the question paper.
Q1 (points 5) Let p be of type int*. Write T or F after each of the following statement
depending on if it is true or false.
#include <stdio.h>
/* swaps values of two variables of type (int *) */
void swapIntPt(int ___1___, int ___2___v){
int ___3___ = *u;
*u = *v;
*v = temp;
}
int main(){
int x=5, y=10;
int *p=&x, *q=&y;
printf("%d,%d\n", (p==&x), (q==&y));
swapIntPt(___4___ , ___5___);
printf("%d,%d\n", (p==&y), (q==&x));
}
In answers to parts (n) below, write the expression that should be lled in places
___n___ so that the program works as described above.
(1) (4)
(2) (5)
(3)
2
Name ............................ Roll no. ................. Section .........
Q3 (points 5) One can write string functions using pointers instead of array index
notation. In such code, one typically uses a pointer to traverse through characters of
a string. Following are two examples of such codes. To understand them you need
to use the fact that int code of character `\0' is 0.
(a)
3
Rough Work