PPS - Unit 5 Objective Questions
PPS - Unit 5 Objective Questions
PPS - Unit 5 Objective Questions
A. a
B. w
C. f
D. t
A. A character string containing the name of the file & the second argument is the mode
B. A character string containing the name of the user & the second argument is the mode
C. A character string containing file pointer & the second argument is the mode
D. None of the mentioned
A. int type
B. char * type
C. struct type
D. None of the mentioned
A. "b"
B. "B"
C. "binary"
D. "01"
8.Which of the following statements about stdout and stderr are true?
A. Same
B. Both connected to screen always.
C. Both connected to screen by default.
D. stdout is line buffered but stderr is unbuffered.
A. .txt
B. .bin
C. .c
D. None of the above
10. When a C program is started, O.S environment is responsible for opening file and providing
pointer for that file?
A. Standard input
B. Standard output
C. Standard error
D. All of the above
11.If there is any error while opening a file, fopen will return?
A. Nothing
B. EOF
C. NULL
D. Depends on compiler
12.It is not possible to combine two or more file opening mode in open () method.
A. True
B. False
14.Which is true?
A.Declared
B. Initialized
D.None of these
B. Different
C. Not related
D.Error
B. int *p;
C. int +p;
D. int $p;
19. Which one of the following is correct syntax for opening a file.
a) FILE *fopen(const *filename, const char *mode)
b) FILE *fopen(const *filename)
c) FILE *open(const *filename, const char *mode)
d) FILE open(const*filename)
21. If the mode includes b after the initial letter, what does it indicates?
a) text file
b) big text file
c) binary file
d) blueprint text
24. Choose the statement which is incorrect with respect to dynamic memory allocation.
a) Memory is allocated in a less structured area of memory, known as heap
b) Used for unpredictable memory requirements
c) Execution of the program is faster than that of static memory allocation
d) Allocated memory can be changed during the run time of the program based on the
requirement of the program
25. Which of the following header files must necessarily be included to use dynamic memory
allocation functions?
a) stdlib.h
b) stdio.h
c) memory.h
d) dos.h
26. The type of linked list in which the node does not contain any pointer or reference to the
previous node is _____________
a) Circularly singly linked list
b) Singly linked list
c) Circular doubly linked list
d) Doubly linked list
28. The advantage of using linked lists over arrays is that ________
a) Linked list is an example of linear data structure
b) Insertion and deletion of an element can be done at any position in a linked list
c) Linked list can be used to store a collection of homogenous and heterogeneous data
types
d) The size of a linked list is fixed
a)100
b)hello
c)“hello”
d) error
30. _______________ is the preprocessor directive which is used to end the scope of #ifdef.
a) #elif
b) #ifndef
c) #endif
d) #if
#include<stdio.h>
void main()
{
#ifndef max
printf("hello");
#endif
printf("hi");
}
a)hello
b)hellohi
c)error
d) hi
33. The preprocessor directive which checks whether a constant expression results in a zero or
non-zero value __________
a)#if
b)#ifdef
c)#undef
d) #ifndef
#include<stdio.h>
#define max 100
void main()
{
#if(max%10)
printf("KEC");
#endif
printf("GHAZIABAD");
}
a)error
b)KEC
c)GHAZIABAD
d) KECGHAZIABAD
35. The preprocessor directive which is used to remove the definition of an identifier which
was previously defined with #define?
a)#ifdef
b)#undef
c)#ifndef
d) #def
36. What will be the output of the following C code?
#include<stdio.h>
#define hello 10
void main()
{
printf("%d",hello);
#undef hello
printf("%d",hello);
}
a)10
b)hello
c)error
d) 1010
#include <stdio.h>
#define a 2
main()
{
int r;
#define a 5
r=a*2;
printf("%d",r);
}
a)10
b)4
c)2
d) 5
41. Which of the following header declares mathematical functions and macros?
a) math.h
b) assert.h
c) stdmat. h
d) stdio. H
#include <stdio.h>
int main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
return 0;
}
a)Compile time error
b) Segmentation fault/runtime crash
c)10
d) Undefined behaviour
intmain()
{
inty = 20;
fun(y);
printf("%d", y);
return0;
}
44. Output of following program?
# include <stdio.h>
voidfun(int*ptr)
{
*ptr = 30;
}
intmain()
{
inty = 20;
fun(&y);
printf("%d", y);
return0;
}
46. Are the expression *ptr++ and ++*ptr are same? _________
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q\n");
else
printf(" nullq\n");
}
int main()
{
int i = 10;
void *p = &i;
printf("%d\n", (int)*p);
return 0;
}
int main()
{
int i = 10;
void *p = &i;
printf("%f\n", *(float*)p);
return 0;
}
int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int j = 10;
return &j;
}
1.D 2.B 3.A 4.C 5.C 6.D 7.A 8.C 9.D 10.D
11.C 12.B 13.D 14.C 15.c 16.a 17.b 18.C 19.A 20.B
21.C 22.D 23.B 24.C 25.A 26.B 27.D 28.B 29.D 30.C
31.B 32.C 33.A 34.D 35.B 36.C 37.A 38.D 39.scanf 40.a
41.a 42.a 43.20 44.30 45.a 46.not 47. 48. 49.00 50.10
same nullp complier
nullq error