0% found this document useful (0 votes)
56 views3 pages

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

This document contains a quiz with multiple choice and true/false questions about computer programming concepts like functions, pointers, and arrays for a course at Mohammad Ali Jinnah University, Islamabad Campus. It has 3 questions - the first asks to determine the output of a C++ program dealing with pointers, the second provides code for a function subtraction and tests calls to it, and the third contains 7 multiple choice questions about functions, pointers, and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views3 pages

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

This document contains a quiz with multiple choice and true/false questions about computer programming concepts like functions, pointers, and arrays for a course at Mohammad Ali Jinnah University, Islamabad Campus. It has 3 questions - the first asks to determine the output of a C++ program dealing with pointers, the second provides code for a function subtraction and tests calls to it, and the third contains 7 multiple choice questions about functions, pointers, and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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