ICT Unit-6 Worksheet 3rd Round C++
ICT Unit-6 Worksheet 3rd Round C++
ICT Work Sheet for Grade 9 Based on Table of Specification in 2017 E.C
I. Write “True” if the following statement is/ are correct otherwise “False”
1.In C++, a variable can be declared without initializing it, and it will automatically have a default value. False
2.The name of a variable in C++ must start with a letter or an underscore. True
3.In C++, variables of different types can be declared in the same statement, separated by commas. True
4.A variable in C++ can be assigned a value after it has been declared, but only once. False
5.C++ identifiers are case-sensitive, meaning variable, Variable, and VARIABLE are treated as different
identifiers. True
6.A variable declared inside a function is accessible outside of that function. False
7.Global variables are accessible throughout the entire program, including inside functions. True
8.In C++, the int data type can hold both integer values and floating-point numbers. False
9.The char data type in C++ is used to store single characters, but it is stored as an integer internally. True
10.A function can be called before it is defined, as long as there is a function prototype (declaration) above
the call. True
11.In C++, you can have multiple functions with the same name if they have different return types. True
12.The if statement in C++ can only evaluate conditions that result in a boolean value. True
13.The continue statement in a loop causes the program to exit the loop and proceed with the next iteration. True
14.The index of the first element in an array in C++ is always 1. False
15.A pointer can be used to store the address of a constant variable, but it cannot modify the value of the
variable it points to. False
44.Which standard namespace is most commonly used in C++? A. io B. system C. main D. std
45.What does the statement using namespace std; do?
A. Imports a class from a library B. Defines a new namespace
C. Tells the compiler to use the std namespace D. Compiles the program
46.What happens if two functions have the same name but are in different namespaces?
A. Compilation error B. The second one overrides the first
C. Runtime warning D. No conflict — namespaces isolate them
47.Which keyword is used to access a specific item from a namespace without using using namespace?
A. from B. with C. namespace D. ::
48.What happens when the compiler encounters a comment in C++ code?
A. It executes the comment B. It raises a syntax error
C. It treats it as code D. It ignores the comment
49.Why are comments used in C++ code? A. To slow down execution B. To make code unreadable
C. To store runtime values D. To describe or explain code
50.Which of the following is a valid comment in C++?
A. # This is a comment B. <!-- This is a comment --> C. // This is a comment D. 'This is a comment'
51.What does the following statement do?
float rate = 4.5;
A. Declares a string variable B. Declares a float variable and assigns it 4.5
C. Declares an integer and initializes it D. Assigns 4.5 to an undeclared variable
52.Which of the following is not a valid variable name in C++?
A. _value B. total1 C. 3score D. value_3
53.Which of the following correctly initializes multiple variables of the same type?
A. int a, b = 5, c = 10; B. int a = b = c = 10; C. int a b c = 5; D. int a == 5, b == 6;
54.Which of the following is a valid string variable declaration in C++?
A. string name = "John"; B. String name = John; C. text name = "John"; D. char name = "John";
55.Which of the following is the correct syntax for taking input from the user in C++?
A. cin >> variable; B. input variable; C. scanf(variable); D. read variable;
56.What is the header file required to use cin and cout in C++?
A. #include <stdio.h> B. #include <input.h> C. #include <iostream> D. #include <cinout.h>>
int main() {
int x = 5, y = 10;
display(x, y);
return 0;
}
A. 10 5 B. 5 10 C. 5 5 D. Compilation error
94.What does a pointer in C++ store?
A. A variable's value B. The address of another variable
C. A constant value D. The return type of a function
95.What is the purpose of the dereference operator (*) in C++?
A. To declare a pointer B. To access the memory address of a variable
C. To access the value stored at the memory address a pointer is pointing to D. To assign a value to a pointer
96.Which of the following is the correct syntax to declare a pointer to an integer in C++?
A. int* ptr; B. pointer int* ptr; C. int ptr*; D. int &ptr; E. pointer int ptr;
97.What is the output of the following code?
int num = 10;
int* ptr = #
cout << *ptr; A. 10 B. The memory address of num C. Undefined behavior D. 0
98.What is the purpose of the & operator when used with a variable in C++?
A. To get the address of the variable B. To dereference the pointer
C. To define a pointer D. To assign a pointer to a variable
99.Which of the following is an example of a pointer to a pointer in C++?
A. int* ptr = # B. int** ptr = &ptr1; C. int* ptr = &ptr1; D. int* ptr = *num;
100.Which of the following correctly initializes a pointer to a constant integer?
A. const int* ptr = # B. int* const ptr = # C. int* ptr = # D. const int ptr = #
cout<<y/x<<endl; 1
//9_____________
0
cout<<x%2<<endl; //10_____________
cout<< ((x>y) && (x<y)) <<endl; 0
//11_____________
0
cout<<((x<y) && (x>y)) <<endl; //12_____________
cout<<((x>y) || (x<y)) <<endl; 1
//13_____________
1
cout<<((x<y) || (x>y)) <<endl; //14_____________
4 10100 & 00110=00100=4
cout<< 20 & 6 <<endl; //15_____________
22
cout<<20 | 6<<endl; //16_____________ 10100 | 00110=11010=22
18 10100 ^ 00110=10010=18
cout<<20 ^ 6<<endl; //17_____________
cout<<~ 3<<endl; -4
//18_____________ 011=011+1=100= -4