Mohammad Ali Jinnah University, Islamabad Campus Quiz#10: Question 1: Determine The Output of The Following Program

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Mohammad Ali Jinnah University, Islamabad Campus

Quiz#10

Course Title Computer Programming (for Engineers)
Instructor Maryam Kausar
Weightage 2%


Question 1: Determine the output of the following program.

int main ()
{
int *x;
int c=200;
int p;
x=&c;
p=*x;

cout << *x << endl;
cout << p << endl;
return(0);
}


X=200
P=200

Question 2:
#include <iostream>
using namespace std;
int subtraction (int a, int b)
{
int r;
r=a-b;
return (r);
}
int main ()
{
int x=5, y=3, z;
z = subtraction (7,2);
cout << "The first result is " << z <<
'\n';
cout << "The second result is " <<
subtraction (7,2) << '\n';
cout << "The third result is " <<
subtraction (x,y) << '\n';
z= 4 + subtraction (x,y);
cout << "The fourth result is " << z <<
'\n';
return 0;
}
}
The first result is 5
The second result is 5
The third result is 2
The fourth result is 6

Question 3: MCQs:

i) Which is not a proper prototype?
A. int funct(char x, char y);
B. double funct(char x)
C. void funct();
D. char x();

ii) What is the return type of the function with prototype: "int func(char x, float v,
double t);"
A. char
B. int
C. float
D. double

iii) Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();

iv) Which of the following is a complete function?
A. int funct();
B. int funct(int x) {return x=x+1;}
C. void funct(int) {cout<<"Hello"}
D. void funct(x) {cout<<"Hello"}

v) C++ functions other than main are executed:
A. Before main executes.
B. After main completes execution.
C. When they are explicitly called by another function.
D. Never.

vi) What does the following statement declare?
int *countPtr, count;
A. Two int variables.
B. One pointer to an int and one int variable.
C. Two pointers to ints.
D. The declaration is invalid

vii) A function that modifies an array by using pointer arithmetic such as ++ptr to process
every value should have a parameter that is:
A. A nonconstant pointer to nonconstant data.
B. A nonconstant pointer to constant data.
C. A constant pointer to nonconstant data.
D. A constant pointer to constant data.

You might also like