Question 1 of 25
Hints left: 3
Q1
What will be the output of the following C++ code? #include <iostream> using namespace std; #define PR(id) cout << "The value of " #id " is "<<id int main() { int i = 10; PR(i); return 0; }
Q2
which keyword is used to define the macros in c++?
Q3
Which keyword is used to check exception in the block of code?
Q4
What will be the output of the following C++ code? #include <iostream> using namespace std; void print(int i) { cout << i; } void print(double f) { cout << f; } int main(void) { print(5); print(500.263); return 0; }
Q5
Where should default parameters appear in a function prototype?
Q6
In which of the following we cannot overload the function?
Q7
How many types do functions fall depends on modularization?
Q8
Which operator is used for accessing a member of namespace?
Q9
Which is more effective while calling the functions?
Q10
Where can the default parameter be placed by the user?
Q11
What will be the output of the following C++ code? #include <iostream> using namespace std; int fun(int=0, int = 0); int main() { cout << fun(5); return 0; } int fun(int x, int y) { return (x+y); }
Q12
What is similar to the interface in c++?
Q13
What will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; void dumplist(int, ...); int main() { dumplist(2, 4, 8); dumplist(3, 6, 9, 7); return 0; } void dumplist(int n, ...) { va_list p; int i; va_start(p, n); while (n-->0) { i = va_arg(p, int); cout << i; } va_end(p); }
Q14
What will happen while using pass by reference?
Q15
Pick the incorrect statement for namespaces in C++.
Q16
What should be passed in parameters when function does not require any parameters?
Q17
What will be the output of the following C++ code? #include <iostream> using namespace std; int operate (int a, int b) { return (a * b); } float operate (float a, float b) { return (a / b); } int main() { int x = 5, y = 2; float n = 5.0, m = 2.0; cout << operate(x, y) <<"\t"; cout << operate (n, m); return 0; }
Q18
What will be the output of the following C++ code? #include <iostream> #include <stdarg.h> using namespace std; int add (int num, ...) { int sum = 0; va_list args; va_start (args,num); for (int i = 0; i < num; i++) { int num = va_arg (args,int); sum += num; } va_end (args); return sum; } int main (void) { int total = add(8, 1, 2, -1, 4, 12, -2, 9, 7); cout << "The result is " << total; return 0; }
Q19
Which operator is used to signify the namespace?
Q20
What will happen when the exception is not caught in the program?
Q21
In which of the following cases inline functions may not word? i. If the function has static variables. ii. If the function has global and register variables. iii. If the function contains loops iv. If the function is recursive
Q22
Which keyword is used to access the variable in the namespace?
Q23
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace A{ int var = 10; } namespace B{ int cout = 5; } int main() { using namespace B; cout<<A::var; }
Q24
What will be the output of the following C++ code? #include <iostream> using namespace std; #define SquareOf(x) x * x int main() { int x; cout << SquareOf(x + 4); return 0; }
Q25
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; namespace { int var = 10; } int main() { cout<<var; }