Full Transcript

QUESTION PAPER: SECTION 1: MCQS 1. What will be the output of the following code? c Copy code #include int main() { int x = 5; printf("%d %d %d", x++, ++x, x); return 0; } a) 6 7 7...

QUESTION PAPER: SECTION 1: MCQS 1. What will be the output of the following code? c Copy code #include int main() { int x = 5; printf("%d %d %d", x++, ++x, x); return 0; } a) 6 7 7 b) 5 7 7 c) Undefined behavior d) 6 6 7 2. Which of the following is a correct way to declare a pointer to a function in C? a) int *func_ptr(int a); b) int (*func_ptr)(int a); c) int (*func_ptr)[]; d) int *func_ptr[]; 3. Which of the following keywords in C is used for creating a constant variable? a) constant b) static c) const d) final 4. Which operator is used to get the size of a datatype in C? a) sizeof b) size c) len d) length 5. What will the following C code output? c Copy code #include int main() { char str[] = "hello"; printf("%s", &str); return 0; } a) hello b) ello c) h d) Syntax error 6. What is the difference between a class and a struct in C++? a) No difference b) class has public members by default, struct has private c) struct has public members by default, class has private d) struct supports inheritance, class does not 7. Which of the following is a valid way to declare a reference variable in C++? a) int &ref = var; b) int ref = &var; c) int *ref = var; d) int var = &ref; 8. Which of the following is the correct syntax to create an object of a class in C++? a) class_name object_name; b) class object_name; c) new class_name(); d) class_name object_name(); 9. What will be the output of the following C++ code? cpp Copy code #include using namespace std; class A { public: A() { cout

Use Quizgecko on...
Browser
Browser