Sunteți pe pagina 1din 9

1. What does the following declaration mean?

int (*ptr)[10];
A.ptr is array of pointers to 10 integers.
B.ptr is a pointer to an array of 10 integers
C.ptr is an array of 10 integers
D.ptr is an pointer to array
Answer-B- ptr is a pointer to an array of 10 integers.
2. What will be output of the following c program?
#include<stdio.h>
int main(){
int goto=5;
printf("%d",goto);
return 0;}
(A) 5.(B) **.(C) **.(D) Compilation error.(E) None of these.

Answer: (D)
3.How many bytes are occupied by near, far and huge pointers (LINUX)?
A. near=2 far=4 huge=4. B. near=4 far=8 huge=8
C. near=2 far=4 huge=8.D. near=4 far=4 huge=4

Answer: (D)
4. Are the expression *ptr++ and ++*ptr are same?
Ans-False.
5. Which of the declaration is correct?
A. int length;B. char int;. C.int long; D.float double;
Ans-A
6. How will you free the allocated memory ?

A. remove(var-name);.B. free(var-name);.C. delete(var-name);.D. dalloc(var-name);


Ans-B
7. Which of the following is not logical operator?
A. &;B. &&;C. ||; D.!
Ans-A
8. How will you print \n on the screen?
A. printf("\n");B. echo "\\n";.C. printf('\n');.D. printf("\\n");
Ans-D.
9.

Int main()

{
printf(%d\n,strlen(123456));
}
A.6.B.7.C.2.D.8
Ans-A
10.

printf(5+Good Morning\n);
}
A.Good Morning;B. Morning;C.M;D.Good
Ans-B
11. Which of the following is not a type of constructor?
A. Copy constructor;B. Friend constructor;C. Default constructor;D. Parameterized constructor
Ans-B
12. What is wild pointer in c?

Ans- A pointer in c which has not been initialized is known as wild pointer
13. What is size of void pointer?
Ans- two byte
14. what is the output of
void main(){
printf("%d",sizeof(5.2));
}
A.6;B.7;C.2;D.8;
Ans- D-8byte
15. Swap two variables without using third variable
Ans#include<stdio.h>
int main(){
int a=5,b=10;
a=b+a;
b=a-b;
a=a-b;
printf("a= %d b= %d",a,b);
16. What is difference between uninitialized pointer and null pointer?
Ans- An uninitialized pointer is a pointer which points unknown memory location while null pointer is
pointer which points a null value or base address of segment.
17.what is the output of the program
void main(){
int x;
for(x=1;x<=5;x++);

printf("%d",x);
A.6;B.7;C.2;D.8;
Ans-A.6.
18. In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;
A.Integer;B.Integer pointer;C.Error in declaration;D.None of above
Ans-B.Integer pointer
19. If the two strings are identical, then strcmp() function returns
A.-1;B.1;C.0;D.Yes
Ans-C.0
20. The keyword used to transfer control from a function back to the calling function is
A.switch;B.goto;C.go back;D.return
Ans-D.return
21. Every function must return a value
A.Yes;B.No
Ans-B.No.
If a function return type is declared as void it cannot return any value.
22. Functions cannot return more than one value at a time
A.True;B.False
Ans.A.True
True, A function cannot return more than one value at a time.
because after returning a value the control is given back to calling function.
23. Is there any difference between the following two statements?
char *p=0;
char *t=NULL;
A.Yes;B.No
Ans.B.NO
NULL is #defined as 0 in the 'stdio.h' file. Thus, both p and t are NULL pointers.
24. Which among the following has the highest precedence?
A. &;B.<<;C.sizeof();D.&&
Ans-C.sizeoff()
25. What is the output of this C code?
#include <stdio.h>
void main()
{

int k;
for (k = -3; k < -5; k++)
printf("Hello");

A)Hello;B)Infinite hello;C)Run time error;D)Nothing

Answers.D
26.

Output of the below code?

#include <stdio.h>
int main()
{

int i = 0;
while (i < 3)
i++;
printf("In while loop\n");

A)2;B)3;C)4;D)1
Ans-C)4.
27. What is the output of this C code?
#include <stdio.h>
void main()
{

double k = 0;
for (k = 0.0; k < 3.0; k++)
printf("Hello");

A)Run time error;B)Hello is printed thrice;C)Hello is printed twice;D)Hello is printed infinitely


Answer:B
28. What is the use of putchar()?
A)The character written;B)EOF is an error occurs;C)Nothing;D)Both a & b
Ans-D.
29. What is the output of this C code?
#include <stdio.h>
int main()
{

int i = 0;
int j = i++ + i;
printf("%d\n", j);

A)0;B)1;C)2;D)Compile time error


Ans-A
30. 7. What is the output of this C code?
#include <stdio.h>
int main()
{

int i = 2;
int j = ++i + i;
printf("%d\n", j);

A)6;B)5;C)4;D)Compile time error


Ans-A
31. Which type is best suited to represent the logical values?
A)integer;B)boolean;C)character;D)all of the mentioned
Answer:B

Explanation: Logical values can be either true or false, so the boolean type is suited for it.
32. Which operator is having the highest precedence?
A)postfix;B)unary;C)shift;D)equality
Answer:A
Explanation:The operator which is having highest precedence is postfix and lowest is equality
33. How many sequence of statements are present in c++?
A)4;B)3;C)5;D) 6
Answer:c
Explanation:There are five sequence of statements.
They are Preprocessor directives,Comments,Declarations,Function Declarations,Executable statements
34. How many types of loops are there?
A)4;B)2;C)3;D)1
Answer:A
Explanation:There are four types of loop. They are while, do while, nested, for loop.
35. Which looping process is best used when the number of iterations is known?
A)for;B)while;C)do-while;D)all looping processes require that the iterations be known
Answer:A
36. What is the default return type of a function ?
A)int;B)void;C)float;D)char
Answer:B
37. What is the index number of the last element of an array with 9 elements?
A)9;B)8;C)0;D)Programmer-defined
Answer:B
38. What is meaning of following declaration?
int(*p[5])();
A)p is pointer to function.;B)p is array of pointer to function.C)p is pointer to such function which
return type is array.D) p is pointer to array of function.
Answer:B
39. Which is used to define the member of a class externally?
A):
b) ::
c) #
d) none of the mentioned
Answer:B
40. Which other keywords are also used to declare the class other than class?
A)struct;B)union;C)object;D)both a & b
Answer:D
Explanation:Struct and union take the same definition of class but differs in the access techniques
41.The fields in the class in c++ program are by default
A)protected;B)private;C)public;D)none of the mentioned
Answer:B

42. Where does the abstract class is used?


A)base class only;B)derived class;C)both a & b;D)None of the mentioned
Answer:A
43. What is meant by multiple inheritance?
A)Deriving a base class from derived class;B)Deriving a derived class from base class;C) Deriving a
derived class from more than one base class;D) None of the mentioned
Answer:C
Explanation:Multiple inheritance enables a derived class to inherit members from more than one
parent
44. How many types of returning values are present in c++?
A)1;B)2;C)3;D)4
Answer:C
Explanation:The three types of returning values are return by value, return by reference and return by
address.
45. How many ways of passing a parameter are there in c++?
A)1;B)2;C)3;D)4
Answer:C
Explanation:There are three ways of passing a parameter. They are pass by value,pass by reference
and pass by pointer.
46. By default how the value are passed in c++?
A)call by value;B)call by reference;C)call by pointer;D)none of the mentioned
Answer:A
47. Which is more effective while calling the functions?
A)call by value;B)call by reference;C)call by pointer;D)none of the mentioned
Answer:B
Explanation:In the call by reference, it will just copy the address of the variable to access it, so it will
reduce the memory in accessing it

48. How many minimum number of functions are need to be presented in c++?
A)0;B)1;C)2;D)3
Answer:B.
Explanation:The main function is the mandatory part, it is needed for the execution of the program to
start.
49. Which is used to return the number of characters in the string?
A)length;B)size;C)both a & b;D)None of the mentioned
Answer:C
Explanation:Both will return the number of characters that conform the strings content.
50. Which keyword is used to handle the expection?
A)try;B)throw;C)catch;D)none of the mentioned
Answer:C

S-ar putea să vă placă și