OOP Languge Skill

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

Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 1 of 6
TTLM
Module Title: Applying OOP Language Skills Quiz Test
NAME ___________________________________ ID. No. _________________
I. chooses the correct answer for the following questions.
1. How do you insert COMMENTS in C++ code?
A. //this is a comment C. /this is a comment
B. #this is a comment D. None of the above
2. What is a correct syntax to output "Hello World" in C++?
A. Console.WriteLine("Hello World"); C. System.out.println("Hello World");
B. print ("Hello World"); D. cout << "Hello World";
What will be the output of the following C++ code?
E.
include <iostream> A. a=4 b=10
using namespace std; B. a=10 b=4
int main () C. a=10 b=7
{ int a, b; D. a=7 b=4
a = 10; b = 4;
cout << "a=" <<a<<endl;
cout << "b=" <<b<<endl;
return 0;
}
3. What will be the output of the following C++ code?
include <iostream> A. a=4 b=10
using namespace std; B. a=10 b=4
int main () C. a=10 b=7
{ int a, b; D. a=4 b=7
a = 10; b = 4;
a=b; b=7;
cout << "a=" <<a<<endl;
cout << "b=" <<b<<endl;
return 0;
}
4. What will be the output of the following C++ code?
include <iostream> A. a=2
using namespace std; B. a=16
int main () C. a=10
{ int a, b; D. a=2
a = 10; b = 2;
a= a>>b;
a= a<<3;
cout << "a=" <<a<<endl;
return 0;
}
5. Write a program in C++ to display the sum of two numbers using variables x=5 and
y=7.
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM
Module Title: Applying OOP Language Skills Quiz Test
NAME ___________________________________ ID. No. _________________
I. chooses the correct answer for the following questions.
1. How do you insert COMMENTS in C++ code?
A. //this is a comment C. /this is a comment
B. #this is a comment D. None of the above
2. What is a correct syntax to output "Hello World" in C++?
A. Console.WriteLine("Hello World"); C. System.out.println("Hello World");
B. print ("Hello World"); D. cout << "Hello World";
What will be the output of the following C++ code?
E.
include <iostream> A. a=4 b=10
using namespace std; B. a=10 b=4
int main () C. a=10 b=7
{ int a, b; D. a=7 b=4
a = 10; b = 4;
cout << "a=" <<a<<endl;
cout << "b=" <<b<<endl;
return 0;
}
3. What will be the output of the following C++ code?
include <iostream> A. a=4 b=10
using namespace std; B. a=10 b=4
int main () C. a=10 b=7
{ int a, b; D. a=4 b=7
a = 10; b = 4;
a=b; b=7;
cout << "a=" <<a<<endl;
cout << "b=" <<b<<endl;
return 0;
}
4. What will be the output of the following C++ code?
include <iostream> A. a=2
using namespace std; B. a=16
int main () C. a=10
{ int a, b; D. a=2
a = 10; b = 2;
a= a>>b;
a= a<<3;
cout << "a=" <<a<<endl;
return 0;
}
5. Write a program in C++ to display the sum of two numbers using variables
x=5 and y=7.
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM
Module Title: Applying OOP Language Skills Quiz Test
NAME ___________________________________ ID. No. _________________
I. chooses the correct answer for the following questions.
1. The modulus operator uses ___ character.
A. * B. % C. / D. +
2. In c , each statement ends with:
++

A. Colon B. point C. semicolon D. slash


3. How would you declare an integer called num and initialize it to 20?
A. int num=20; B. int num20; C. int num; num=20; D A &C
4. What is the correct way to display integer sum to the screen?
A. cout<<sum<<endl; C. cout>>sum>>endl;
B. cout<<"sum"<<endl; D. cin>>sum>>endl;
5. What will be the output of the following C++ code?
int main() A. 30
{ int a=32; B. 32
do C. 33
{ cout <<a; D. 31
a++;
}while(a <= 30);
return 0;
}
6. What should be the output of below program?
int main() A. one
{ int a = 2; B. Two
switch(a) C. Three
{ case 1: cout<<"One"; break; D. Default
case 2: cout<<"Two"; break;
case 3: cout<<"Three"; break;
default: cout<<"Default";
}
return 0;
}
7. What should be the output of below program?
int main() A. X is the smallest
{ int x = 2, y = 4; B. Y is the largest
x=6; C. X is the largest
if(x>y) D. Y is the smallest
cout<<"X is the largest";
else
cout<<"Y is the largest";
return 0;
}
8. Write a program in c++ that displays the sum of numbers from 1 to 10 using for loop.
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM
Module Title: Applying OOP Language Skills Quiz Test
NAME ___________________________________ ID. No. _________________
I. chooses the correct answer for the following questions.
1. The modulus operator uses ___ character.
A. * B. % C. / D. +
2. In c , each statement ends with:
++

A. Colon B. point C. semicolon D. slash


3. How would you declare an integer called num and initialize it to 20?
A. int num=20; B. int num20; C. int num; num=20; D A &C
4. What is the correct way to display integer sum to the screen?
A. cout<<sum<<endl; C. cout>>sum>>endl;
B. cout<<"sum"<<endl; D. cin>>sum>>endl;
5. What will be the output of the following C++ code?
int main() A. 30
{ int a=32; B. 32
do C. 33
{ cout <<a; D. 31
a++;
}while(a <= 30);
return 0;
}
6. What should be the output of below program?
int main() A. one
{ int a = 2; B. Two
switch(a) C. Three
{ case 1: cout<<"One"; break; D. Default
case 2: cout<<"Two"; break;
case 3: cout<<"Three"; break;
default: cout<<"Default";
}
return 0;
}
7. What should be the output of below program?
int main() A. X is the smallest
{ int x = 2, y = 4; B. Y is the largest
x=6; C. X is the largest
if(x>y) D. Y is the smallest
cout<<"X is the largest";
else
cout<<"Y is the largest";
return 0;
}
8. Write a program in c++ that displays the sum of numbers from 1 to 10 using for loop.
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM
Module Title: Applying OOP Language Skills Exam Test
NAME ___________________________________ ID. No. _________________
I. chooses the correct answer for the following questions.
1. How do you insert COMMENTS in C++ code?
A. // this is a multiple comment C. /* this is a multiple comment*/
B. # this is a multiple comment D. None of the above
2. What is the output of the following program?
int main () A. Hello
{ int x = 1; B. Hi
switch(x) { C. HelloHi
case 1 : D. None of them
cout << "Hi!" << endl;
break;
default :
cout << "Hello!" << endl;
}
}
3. Compiler generates _______ file. A. source code B. object code
C. text file D. none of the above
4. Which statement is used to receive data from keyboard?
A. cout>> B. cin>> C. cin<< D. cout<<
5. What is the size of an int data type?
A. 4 bytes B. 1 bytes C. 2 bytes D. 8 bytes
6. What will be the output of the following C++ code?
int main() A. 25
{ int a,b,c; B. 50
a = 10, b = 15; C. 20
a = 2 * a; b = 2 * b; D. 15
c = a + b;
cout << c;
return 0;
}
7. In which loop the condition is checked after the execution of statements?
A. do..while B. while C. for
8. What will be the output of the following C++ code?
int main() A. 0 1 2 3
{int i; B. 4
for (i = 0; i < 4; i++) C. 0 1 2 3 4
{ D. compiler error
cout << i<<” “;
}
return 0;}
}
9. Which one is not a loop?
A. while B. for C. do..while D. have
10. What loop needs a semicolon?
A. while B. for C. do..while D. have
Institution Name Document No.

ወ/ሮ ስህን ፖሊቴክኒክ ኮሌጅ OF/WSPC /263-01


W/R SIHEEN POLYTECHNIC COLLEGE
Title: Issue No. Page No.
2 Page 4 of 6
TTLM

11. What will be the output of the following C++ code?


int main() A. 0 1 2 3
{int i; B. 4
for (i = 0; i < 4; i++); C. 0 1 2 3 4
{ D. compiler error
cout << i<<” “;
}
return 0;}
}
12. Which of the following correctly declares an array with 5 elements of integer?
A. int array[5]; C. array{5};
B. int array; D. array array[5];
13. Which of the following gives the memory address of the first element in array?
A. array[0]; B. array[1]; C. array[2]; D. array(0);
14. What will be the output of the following C++ code?
int main () A. 5 4 3 2
{int n; B. 5 2
for (n = 5; n > 0; n--) C. 5 4 3
{ D. 5 3
cout << n<<" ";
if (n == 3)
break;
}
return 0;
}
II Answer the following question:
15. Find any errors in the following c++ program (3 pts).
#include<iostream>
using namespace std;
int main()
{/* This is the main function*/
cout<<"Hello, the error is on here!"
return 0;
}
16. Write the output of the following c++ program (3 pts).
#include <iostream>
using namespace std;
int main ()
{int num[3] = {2,6,8};
num[0] = {5};
for (int i = 0; i < 3; i++)
{
cout <<num[i]<<" ";
}
return 0;
}
17. Write a c++ program that display the sum of numbers from 1 to 10 using while loop
(4 pts).

You might also like