ISLAMIC UNIVERSITY OF GAZA
COMPUTER ENGINEERING DEPARTMENT
C++ PROGRAMMING LANGUAGE LAB
QUIZ # 5
Name:
Number:
Q1) Choose the best answer [4 pts]:
1. Which is not a proper prototype?
A. int funct(char x, char y);
B. double funct(char x)
C. void funct();
D. char x();
2. 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
3. Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();
4. 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&tl;<"Hello"}
D. void funct(x) {cout<<"Hello"}
Q2) Write the output of the following programs [6 pts]:
1
#include<iostream>
using namespace std;
void Demo( int intVal, double& doubleVal ) {
intVal = intVal * 2;
doubleVal = double(intVal) + 3.5;
}
int main ()
{
int myInt = 20;
double myDble = 4.8;
Demo(myInt, myDble);
cout << "myInt = " << myInt<< " and myDble = " << myDble ;
system("PAUSE");
return(0);
}
2
3
#include<iostream>
using namespace std;
int Power(int& Base, int& Exponent ) {
int Product = 1;
while (Exponent >= 1) {
Product = Product * Base;
Exponent--;
}
return Product;
}
int main ()
{
int N = 2;
int Pow = 3;
int Result = Power(N, Pow);
cout << N << " to the power " << Pow << " is " << Result;
system("PAUSE");
return(0);
}
#include <iostream>
using namespace std;
void Try( int& a, int b );
int x, y, z;
int main( ) {
x = 1;
y = 2;
z = 3;
Try(y, x);
cout << x << ' ' << y << ' ' << z << endl;
system("PAUSE");
return 0;
}
void Try( int& a, int b ) {
int x;
x = a + 2;
a = a * 3;
b = x + a;
}
1) 10 6 3
2) 10 2 3
3) 1 2 3
4) 1 6 3
5) None of these
© Copyright 2026 Paperzz