Thursday, July 29, 2010
C Question Set 1-6
Question 1
What is the output of the program?
#include <stdio.h>
// Assume size of integer as 4 bytes
void main()
{
char (*p)[3];
printf("\n %d %d", sizeof(*p), sizeof(p));
}
12 4
3 4
1 3
4 12
Question 2
What is the output of the program?
#include <stdio.h>
void main()
{
const char* ptr = "Genesis";
printf(" %c ", (*++ptr)++);
}
No error, output is e
No error, output is n
No error, output is G
l-value specifies const object
Question 3
The functionality of "ferror(FILE *)" is
ferror is a macro that tests the given stream for a read error only
ferror is a macro that tests the given stream for a file open error
ferror is a macro that tests the given stream for a read or write error
ferror is a macro that tests the given stream for a file close error
Question 4
Which of the following function does not return an integer value?
printf
scanf
strcpy
strlen
Question 5
What is the output of the program?
#include <stdio.h>
main()
{
static char Arr[8] = "Genesis";
char* ptr = &Arr[6] - 3;
printf("\n %s", ptr);
}
e
sis
esis
n
Question 6
Which of the following functions support dynamic memory allocation?
malloc
realloc
calloc
All the three A, B and C
Question 7
What is the significance of putw() function?
writes only character data to the file in text mode
writes only integer data to the file in binary mode
writes integer data to the file in text mode
writes character data to the file in binary mode
Question 8
What is the output of the program?
#include <stdio.h>
main()
{
for( ; ; )
main();
}
Error: syntax error at or before;
Executes once
It will result in infinite loop until stack overflow occurs
Error: illegal call to function main()
Question 9
What is the output of the program?
#include <stdio.h>
// Assume integer is 4 bytes
struct {
char *p;
int (*fun)();
} a;
void main()
{
printf("\n %d %d %d ", sizeof(a), sizeof(a.p), sizeof(a.fun));
}
8 4 4
5 1 4
6 2 4
Error: pointer to functions is not allowed in structures
Question 10
What is the output of the program?
#include <stdio.h>
void main()
{
int Var = 90;
if(Var += Var == ++Var == 89)
printf(" %d ",Var);
}
180
91
90
182
Question 11
Which of the functions always write the output to Video Display Unit?
puts
putc
putch
fputs
Question 12
Which of the declarations cannot be performed above main()?
variables of auto storage class
enum declaration
variables of extern storage class
static union declaration
Question 13
What is the output of the program if the input is 103?
main()
{
int p = 234;
printf(" %d ", printf("%d", p), scanf("%d", &p));
}
3 103
103
103 3
103 2
Question 14
What is the difference between scanf() and gets() while scanning a bunch of characters??
scanf() takes input from stdin, but gets() gets input from console
scanf() put a null at the end of the string, but gets() does not
gets() can scan even the spaces, but scanf() cannot
None of the above
Question 15
Which of the functions compares two strings ignoring the case?
strcmp
strncmp
stricmp
strcpy
Question 16
What is the output of the program?
int fun(int num)
{
return printf(" %d ", num);
}
void main()
{
printf(" Genesis ", fun(123), " & Genesis");
}
123 Genesis
Genesis 123
3 Genesis
None of the above
Question 17
What is the output of the program?
void print(char *s)
{
if(*s)
print(++s);
printf("%c", *s);
}
main()
{
char str[] = "Genesis";
print(str);
}
genesis
sisene
siseneg
None of the above
Question 18
Where will the output of the program be printed?
main()
{
fprintf(stdprn, "Genesis InSoft Limited") ;
}
Standard output device
Standard error output device
Standard auxiliary device
Standard printer
Question 19
What is the output of the program?
const int MAX = 15;
void main()
{
enum e{a, b, MAX};
printf("%d %d %d", a, b, MAX);
}
0 1 2
1 2 3
1 2 15
0 1 15
Question 20
What is the purpose of the fcloseall() function?
closes all the streams including standard streams
closes all the streams other than standard streams
closes all the input streams
closes all the output streams
Answers
Answer 1 - B
Answer 2 - D
Answer 3 - C
Answer 4 - C
Answer 5 - C
Answer 6 - D
Answer 7 - B
Answer 8 - C
Answer 9 - A
Answer 10 - B
Answer 11 - C
Answer 12 - A
Answer 13 - C
Answer 14 - D
Answer 15 - C
Answer 16 - A
Answer 17 - B
Answer 18 - D
Answer 19 - A
Answer 20 - B
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment