1.
|
How will you free the allocated
memory ?
|
|||||||
|
Answer: Option B
2.
|
What is the similarity between a
structure, union and enumeration?
|
|||||||
|
Answer: Option B
3. What will be the output of the program ?
#include<stdio.h>
int
main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0]=3;
u.ch[1]=2;
printf("%d, %d, %d\n", u.ch[0],
u.ch[1], u.i);
return 0;
}
Answer: Option A
Explanation:
The system will allocate 2 bytes for the union.
4. #include<stdio.h>
int
main()
{
union var
{
int a, b;
};
union var v;
v.a=
10;
v.b=
20;
printf(
"%d\n", v.a);
return
0;
}
Answer: Option B
5. Point out the error in the program?
struct
emp
{
int ecode;
struct emp *e;
};
Error: in structure declaration
|
|
Linker Error
|
|
No Error
|
|
None of above
|
Answer: Option C
6. If the
two strings are identical, then strcmp() function
returns |
||||||||
|
Answer: Option C
Explanation:
Declaration: strcmp(const char *s1,
const char*s2);
The strcmp return an int value that is
if s1 < s2 returns a
value < 0
if s1 == s2 returns 0
if s1 > s2 returns a
value > 0
7.How will you print \n on the screen?
|
||||||||
|
Answer: Option D
Explanation:
The statement printf("\\n"); prints '\n' on the screen.
8.Which of the following function is correct that finds the
length of a string?
|
||||||||
|
(a)
9.What function should be used to free the memory allocated
by calloc() ?
|
||||||||
|
(c)
10.
How will you free the memory
allocated by the following program?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main()
{
int **p, i, j;
p = (int **) malloc(MAXROW *
sizeof(int*));
return 0;
}
|
||||||||
|
Answer: Option D
11. What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>
int
main()
{
int *p;
p = (
int *)malloc(
20);
/* Assume p has address of 1314 */
free(p);
printf(
"%u", p);
return
0;
}
(a)
12.
What will be the output of the program (16-bit platform)?
#include<stdio.h>
#include<stdlib.h>
int
main()
{
int *p;
p = (
int *)malloc(
20);
printf(
"%d\n",
sizeof(p));
free(p);
return
0;
}
Answer: Option A
13.
What will be the output of the program?
#include<stdio.h>
#include<string.h>
int
main()
{
char *s;
char *fun();
s = fun();
printf(
"%s\n", s);
return
0;
}
char
*fun()
{
char buffer[
30];
strcpy(buffer,
"RAM");
return (buffer);
}
Answer: Option B
14. Point
out the error in the following program.
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *a[3];
a = (int*) malloc(sizeof(int)*3);
free(a);
return 0;
}
|
||||||||
|
Answer: Option B
15.
malloc() returns a float pointer
if memory is allocated for storing float's
and adouble pointer if memory is
allocated for storing double's.
|
||||
|
Answer: Option B
16. Which is an indirection operator among
the following?
a) &
b) *
c) ->
d) .
a) &
b) *
c) ->
d) .
Answer: Option B
17. Which of the following does not initialize
ptr to null (assuming variable declaration of a as int a=0;?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned
18. What is the output of
this C code?
#include <stdio.h>
int x = 0;
void main()
{
int *ptr
= &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}
a) Same address
b) Different address
c) Compile time error
d) Varies
b) Different address
c) Compile time error
d) Varies
19. For a typical program, the
input is taken using.
a) scanf
b) Files
c) Command-line
d) None of the mentioned
a) scanf
b) Files
c) Command-line
d) None of the mentioned
Answer: Option A
20. The value of EOF is_____.
a) -1
b) 0
c) 1
d) 10
a) -1
b) 0
c) 1
d) 10
Answer: Option A
21. Which is true?
a) The symbolic constant EOF is defined in
b) The value is typically -1,
c) Both a & b
d) Either a or b
a) The symbolic constant EOF is defined in
b) The value is typically -1,
c) Both a & b
d) Either a or b
Answer: Option C
22. What is the use of putchar()?
a) The character written
b) EOF is an error occurs
c) Nothing
d) Both a & b
a) The character written
b) EOF is an error occurs
c) Nothing
d) Both a & b
Answer: Option C
23. 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) Same
b) Both connected to screen always.
c) Both connected to screen by default.
d) stdout is line buffered but stderr is unbuffered.
(d)
24. What is the output of
this C code?
#include <stdio.h>
void main()
{
int x = 0;
int *ptr
= &5;
printf("%p\n", ptr);
}
(d)
25.
What does fp point to in the program ?
#include<stdio.h>
int main()
{
FILE *fp;
fp=fopen("trial", "r");
return 0;
}
|
||||||||
|
Answer: Option B
26. What does the following
segment of code do?
fprintf(fp, “Copying!”);
a) It writes “Copying!” into the file pointed by fp
b) It reads “Copying!” from the file and prints on display
c) It writes as well as reads “Copying!” to and from the file and prints it
d) None of the mentioned
fprintf(fp, “Copying!”);
a) It writes “Copying!” into the file pointed by fp
b) It reads “Copying!” from the file and prints on display
c) It writes as well as reads “Copying!” to and from the file and prints it
d) None of the mentioned
Answer: Option A
27.What
is (void*)0?
|
||||||||
|
Answer: Option A
28.In
which header file is the NULL macro defined?
|
||||||||
|
Answer: Option C
Explanation:
The macro "NULL"
is defined in locale.h, stddef.h, stdio.h, stdlib.h, string.h, time.h, and
wchar.h.
29. The first and second arguments of fopen
are
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 poniter & the second argument is the mode.
d) None of the mentioned of the mentioned
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 poniter & the second argument is the mode.
d) None of the mentioned of the mentioned
Answer:a
30. Which of the following mode argument is
used to truncate?
a) a
b) f
c) w
d) t
a) a
b) f
c) w
d) t
Answer:c
No comments:
Post a Comment