Professional Documents
Culture Documents
Itp Final Obj Fall17
Itp Final Obj Fall17
Itp Final Obj Fall17
Part I (Objective)
p = q; A) True B) False
p = x; A) True B) False
*p = q; A) True B) False
ii) [1] A variable for which memory remains allocated as long as the program executes is
called a static variable.
A) True
B) False
iv) [1] Parameters allow you to use different values each time the function is called.
A) True
B) False
vi) [1] A sequential search of a list assumes that the list elements are sorted in ascending
order.
A) True
B) False
vii) [1] Selection sort tries to sort the array after dividing array into two sub-parts.
A) True
B) False
viii) [1] To search an element from a sorted array, we always need to traverse the whole
array.
A) True
B) False
ix) [1] In C++, a string is any sequence of characters enclosed between double quotation
marks.
A) True
B) False
xi) [1] Because strings are stored in arrays, individual characters in the string can be
accessed using the array component access notation.
A) True
B) False
xv) [1] 25 elements are reserved in 2-D array with the following statement?
int ara[5][6];.
A) True
B) False
xvi) [1] To access an element of a two-dimensional array, you need a pair of indices: one for
the row position and one for the column position.
A) True
B) False
xvii) [1] In a two-dimensional array, the rows are numbered 0 to ROW_SIZE -1 and the
columns are numbered 0 to COLUMN_SIZE -1.
A) True
B) False
Write the output of following questions. Please note that programs are error free.
i)
void main()
{
int beta[3][3];
for (int i = 0; i< 3; i++)
for (int j = 0; j < 3; j++)
beta[i][j] = 5 * (i + j);
ii)
int mystery(int num)
{
int y = 1;
if (num == 0)
return 1;
else if (num< 0)
return -1;
else
for (int count = 1; count <num; count++)
y = y * num;
return y;
}
void main()
{
cout<<mystery(2) <<endl;
cout<<mystery(0) <<endl;
cout<<mystery(-2) <<endl;
}
OUTPUT :
OUTPUT :
iv)
void main()
{
string name="Capitaly";
int j = 3;
while (name[j] != '\0')
cout<< name[j++];
cout<<name.length();
cout<<name;
name=name + ”country”;
cout<<name;
}
OUTPUT:
employeeType employees[20];
employeeType newEmployee;
newEmployee.address.city = "Islamabad";
newEmployee.pID = 19;
newEmployee.salary = 45000;
employeeType anotherEmployee;
anotherEmployee = newEmployee;
employees[0].salary = 36000;
employees[0].dept = 3;
employees[19] = employees[0];
employees[19].pID = 1019;
int lastpID = employees[19].pID+1;
cout<<anotherEmployee.salary<<endl;
cout<< (employees[19].salary + newEmployee.salary)/2<<endl;
cout<<lastpID<<endl;
if(employees[19].salary<40000)
cout<<"Employee has an average salary."<<endl;
}
cout<<employees[19]. pID;
employees[0].dept
OUTPUT: