Output of Program-Introduction to Programming-Quiz Solution, Exercises of Computer Programming

This quiz was taken by Sir Raza Muhammad at Quaid-i-Azam University for Introduction to Programming course. It includes: Computer, Programming, Subtraction, Result, Prototype, Return, Type, Valid, Function, Call

Typology: Exercises

2011/2012

Uploaded on 07/13/2012

asim.amjid
asim.amjid 🇵🇰

4.4

(47)

41 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
docsity.com
pf3

Partial preview of the text

Download Output of Program-Introduction to Programming-Quiz Solution and more Exercises Computer Programming in PDF only on Docsity!

Mohammad Ali Jinnah University, Islamabad Campus

Quiz#

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=

P=

Question 2:

#include 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: MCQ’s:

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.