1.
Which of the following is a correct identifier in C++?
3.
What is the use of the indentation in c++?
4.
By default, all the files in C++ are opened in _________ mode.
5.
What will be the output of the following C++ code?
#include
#include
using namespace std;
int main(int argc, char const *argv[])
{
char s1[6] = "Hello";
char s2[6] = "World";
char s3[12] = s1 + " " + s2;
cout<<s3;
return 0;
}
6.
What is the value of p in the following C++ code snippet?
- #include
- using namespace std;
- int main()
- {
- int p;
- bool a = true;
- bool b = false;
- int x = 10;
- int y = 5;
- p = ((x | y) + (a + b));
- cout << p;
- return 0;
- }
7.
What will be the output of the following C++ code?
#include
using namespace std;
int main ()
{
int cin;
cin >> cin;
cout << "cin: " << cin;
return 0;
}
8.
Which of the following approach is used by C++?
9.
Which is more effective while calling the C++ functions?
10.
Which of the following user-defined header file extension used in c++?
11.
Which of the following is used to terminate the function declaration in C++?
12.
Which of the following is used for comments in C++?
13.
What is the difference between delete and delete[] in C++?
14.
What will be the output of the following C++ function?
- int main()
- {
- register int i = 1;
- int *ptr = &i;
- cout << *ptr;
- return 0;
- }
15.
What is virtual inheritance in C++?
16.
What will be the output of the following C++ program?
#include
#include
#include
using namespace std;
int main(int argc, char const *argv[])
{
const char *a = "Hello\0World";
cout<<a;
return 0;
}
17.
What will be the output of the following C++ code?
- #include
- #include
- #include
- using namespace std;
- int main()
- {
- string s = "spaces in text";
- s.erase(remove(s.begin(), s.end(), ' ' ), s.end() ) ;
- cout << s << endl;
- }
18.
What happens if the following program is executed in C and C++?
#include
int main(void)
{
int new = 5;
printf("%d", new);
}
19.
What will be the output of the following C++ code?
- #include
- using namespace std;
- int main()
- {
- char c = 74;
- cout << c;
- return 0;
- }
20.
Which of the following correctly declares an array in C++?
21.
What will be the output of the following C++ program?
- #include
- #include
- using namespace std;
- int main()
- {
- cout << setprecision(17);
- double d = 0.1;
- cout << d << endl;
- return 0;
- }
22.
What happens if the following program is executed in C and C++?
#include
void func(void)
{
printf("Hello");
}
void main()
{
func();
func(2);
}
23.
Which of the following type is provided by C++ but not C?
24.
What happens if the following C++ statement is compiled and executed?
int *ptr = NULL;
delete ptr;
25.
What is the size of wchar_t in C++?
26.
Which of the following is correct about this pointer in C++?
27.
Which of the following is not a type of Constructor in C++?
28.
Which of the following C++ code will give error on compilation?
================code 1=================
#include
using namespace std;
int main(int argc, char const *argv[])
{
cout<<"Hello World";
return 0;
}
========================================
================code 2=================
#include
int main(int argc, char const *argv[])
{
std::cout<<"Hello World";
return 0;
}
========================================