You are on page 1of 4

1) Which of the following special symbol allowed in a variable name? A. B. * (asterisk) - (hyphen) B. D.

| (pipeline) _ (underscore)

Ans: Option D 2) How would you round off a value from 1.66 to 2.0? A. C. ceil(1.66) roundup(1.66) B. D. Floor(1.66) Roundto(1.66)

Ans: Option A 3) What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h> int main() { extern int i; i = 20; printf("%d\n", sizeof(i)); return 0; } A. 2 B. 4 C. vary from compiler D. Linker Error: Undefined symbol 'i' Ans: Option D 4. Which of the following type of class allows only one object of it to be created? A. B. C. D. Virtual class Abstract class Singleton class Friend class

Ans: Option C 5. Which of the following is not the member of class? A. B. C. D. Static function Friend function Const function Virtual function

Ans: Option B 6. When we mention the prototype of a function? A. C. Defining Prototyping B. D. Declaring Calling

Ans: Option B 7. Which of the following factors supports the statement that reusability is a desirable feature of a language? A. B. C. D. It decreases the testing time. It lowers the maintenance cost. It reduces the compilation time. Both A and B.

Ans: Option D 8. Which of the following is not a type of inheritance? A. C. Multiple B. Distributive Multilevel D. Hierarchical

Ans: Option C 9. Which of the following is a mechanism of static polymorphism? A. B. C. D. Operator overloading Function overloading Templates All of the above

Ans: Option D 10. What happens if the base and derived class contains definition of a function with same prototype? A. B. C. D. Compiler reports an error on compilation. Only base class function will get called irrespective of object. Only derived class function will get called irrespective of object. Base class object will call base class function and derived class object will call derived class function.

Ans: Option D 11. What will be the output of the following program? #include<iostream.h> class Bix { public: int x; }; int main() { Bix *p = new Bix(); (*p).x = 10; cout<< (*p).x << " " << p->x << " " ; p->x = 20; cout<< (*p).x << " " << p->x ; return 0; } Ans: 10 10 20 20 12. Write a program in C to display a message without using semi colon anywhere in program Ans: #include <stdio.h> void main() { if(printf(Hello)) {} } We can write the printf inside while or switch as well for same result

13. What will be printed as the result of the operation below: main() { int x=20,y=35; x=y++ + x++; y= ++y + ++x; printf(%d%dn,x,y); } Ans: 5794 14. What is the difference between %d and %*d in c language? Ans: %*d give the address of the variable. 15. What is the difference between i++ and i+1 ? Ans: i++ is an increment and assign to i but i+1 is just an increment of i, but it doesnt mean the value in i got changed here. 16. Difference between structure and union? Ans: Union allocates the memory equal to the maximum memory required by the member of the union but structure allocates the memory equal to the total memory required by the members. 17. Difference between *p and **p? Ans: *p is a simple pointer which holds the address of another variable while **p is a double pointer which holds address of the pointer in which actual address of the another variable is stored. 18. What is the difference between macros and inline functions? Ans: Macro- does not involve in compilation if there is any logical error also just replaces the code inline- look like function, but control doesn't goes to function and execute, it simply replaces the code like macro but involves in compilation. 19. What is pre-processor? Ans: Preprocessor directives are not the libraries which should be included while writing a program .But it is a notation used to include the libraries which are included in the header part of a program 20. What is the difference between printf() and sprintf()? Ans: sprintf() writes data to the character array whereas printf(...) writes data to the standard output device. 21. Define recursion in C. Ans: Calling a function by itself is known as recursion. 22. What is the difference between the Boolean & operator and the && operator? Ans: The Boolean && operator is used for determining two relational expressions and returns true if only if both returns true, otherwise returns false The Boolean & operator is used to perform Boolean operations on bits of two given arithmetic expressions 23. What are the differences between malloc() and calloc()? Ans: There are 2 differences. First, is in the number of arguments. malloc() takes a single argument(memory required in bytes), while calloc() needs 2 arguments(number of variables to allocate memory, size in bytes of a single variable).Secondly, malloc() does not initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.

You might also like