0% found this document useful (0 votes)
46 views8 pages

Quiz 1 C++

The document contains a 30 question quiz about basic C++ programming concepts. The questions cover topics like hardware, binary, data types, functions, I/O streams, variables, operators, comments, preprocessor directives and more. Answering the quiz questions would test a student's fundamental understanding of C++.

Uploaded by

nuraina3907
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)
46 views8 pages

Quiz 1 C++

The document contains a 30 question quiz about basic C++ programming concepts. The questions cover topics like hardware, binary, data types, functions, I/O streams, variables, operators, comments, preprocessor directives and more. Answering the quiz questions would test a student's fundamental understanding of C++.

Uploaded by

nuraina3907
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/ 8

QUIZ 1 (5%)

PROGRAMMING IN C++ (PRG 144)


JANUARY 2021 – MARCH 2021 ACADEMIC SESSION

Answer the following questions.

1. ________ is the physical aspect of the computer that can be seen.


A. Hardware
B. Software
C. Operating system
D. Application program

2. __________ is the brain of a computer.


A. Hardware
B. CPU
C. Memory
D. Disk

3. The speed of the CPU may be measured in __________.


A. megabytes
B. gigabytes
C. megahertz
D. gigahertz

4. Why do computers use zeros and ones?


A. because combinations of zeros and ones can represent any numbers and
characters.
B. because digital devices have two stable states and it is natural to use one state for 0
and the other for 1.
C. because binary numbers are simplest.
D. because binary numbers are the bases upon which all other number systems are
built.

5. One byte has ________ bits.


A. 4
B. 8
C. 12
D. 16

1
6. ____________ is a device to connect a computer to a local area network (LAN).
A. Regular modem
B. DSL
C. Cable modem
D. NIC

7. ____________ are instructions to the computer.


A. Hardware
B. Software
C. Programs
D. Keyboards

8. Computer can execute the code in ____________.


A. machine language
B. assembly language
C. high-level language
D. none of the above

9. ___________ translates high-level language program into machine language program.


A. An assembler
B. A compiler
C. CPU
D. The operating system

10. ____________ is an operating system.


A. Java
B. C++
C. Windows XP
D. Visual Basic
E. Ada

11. _____________ is a program that runs on a computer to manage and control a


computer's activities.
A. Operating system
B. C++
C. Modem
D. Interpreter
E. Compiler

2
12. ________ is an object-oriented programming language.
A. Java
B. C++
C. C
D. C#
E. Python

13. The main function header is written as:


A. public static void main(string[] args)
B. public int main(String[] args)
C. int main()
D. public static main(String[] args)
E. public void main(String[] args)

14. Which of the following statements is correct to display Welcome to C++ on the console?
A. cout << "Welcome to C++";
B. cout >> "Welcome to C++";
C. cout < "Welcome to C++";
D. cout << 'Welcome to C++';
E. System.out.print("Welcome to C++");

15. Which of the following statements is correct?


A. Every line in a program must end with a semicolon.
B. Every statement in a program must end with a semicolon.
C. Every comment line must end with a semicolon;
D. Every function must end with a semicolon;
E. Every preprocessor directive must end with a semicolon;

16. A preprocessor directive begins with a symbol __________.


A. <
B. >
C. @
D. #
E. *

17. C++ compiler translates C++ source code into _________.


A. Java code
B. machine code
C. C code
D. another high-level language code

3
18. Suppose you define a C++ as follows:

int main()
{

The source code should be stored in a file named


A. Test.cpp
B. Test.doc
C. Test.txt
D. Test.java
E. Any name with extension .cpp

19. The extension name of a C++ object file on Windows is


A. .java
B. .obj
C. .class
D. .exe

20. The extension name of a C++ source code file is


A. .java
B. .obj
C. .class
D. .exe
E. .cpp

21. Which of the following lines is not a C++ comment?


A. /** comments */
B. // comments
C. -- comments
D. /* comments */
E. ** comments **

22. Every statement in C++ ends with ________, which is called a statement terminator.
A. a semicolon (;)
B. a comma (,)
C. a period (.)
D. an asterisk (*)

23. ___________ is called a stream insertion operator for sending output to the console.

4
A. a semicolon (;)
B. a comma (,)
C. a period (.)
D. an asterisk (*)
E. <<

24. A block is enclosed inside __________.


A. Parentheses
B. Braces
C. Brackets
D. Quotes

25. The following program displays __________.

#include <iostream>
using namespace std;

int main()
{
cout << 1 + 2 << endl;

return 0;
}

A. 1 + 2
B. 2
C. 12
D. 3
E. 1

26. The following program displays __________.

#include <iostream>
using namespace std;

int main()
{
cout << "A";
cout << "B";

return 0;
}

A. A B

5
B. AB
C. B A
D. BA

27. Programming style is important, because ______________.


A. a program may not compile if it has a bad style
B. good programming style can make a program run faster
C. good programming style makes a program more readable
D. good programming style helps reduce programming errors

28. Analyze the following code.

I:
#include <iostream>
using namespace std;

int main()
{
cout << "Welcome to C++" << endl;
return 0;
}

II:
#include <iostream>
using namespace std;

int main() { cout << "Welcome to C++" << endl; return 0; }

A. Both I and II can compile and run and display Welcome to C++, but the code in II has
a better style than I.
B. Only the code in I can compile and run and display Welcome to C++.
C. Only the code in II can compile and run and display Welcome to C++.
D. Both I and II can compile and run and display Welcome to C++, but the code in I has
a better style than II.

29. Which of the following code has the best style?

I:
#include <iostream>
using namespace std;

int main()
{
cout << "Welcome to C++" << endl;

6
return 0;
}

II:
#include <iostream>
using namespace std;

int main()
{
cout << "Welcome to C++" << endl;
return 0;
}

III:
#include <iostream>
using namespace std;

int main()
{ cout << "Welcome to C++" << endl;
return 0;
}

IV:
#include <iostream>
using namespace std;

int main()
{
cout << "Welcome to C++" << endl;
return 0;
}
A. I
B. II
C. III
D. IV

30. If a program compiles fine, but it produces incorrect result, then the program suffers
__________.
A. a compilation error
B. a runtime error
C. a logic error

>>>>>>>end of question<<<<<<

7
8

You might also like