1.What would be the Output of the following program?
main()
{
char *str[] = {“Frog”,”Do”,”Not”, “Die.”,”They”,”Croak!”};
printf(“%d %d”, Sizeof (str), sizeof (str[0]));
}
a) 3 12
b) 2 12
c) 12 3
d) 12 2
ANSWER: D
2.What would be the output of the following program?
main()
{
char str1[] = “Hello”;
char str2[] = “Hello”;
if(str1 == str2)
printf(“Equal”);
else
printf(“\nUnequal”);
}
a) Error.
b) Equal.
c) Unequal.
d) None.
ANSWER: C
3.Would the following Code give any error on compilation?
strcat (string,’!’);
a) Yes.
b) No.
ANSWER: A
4.What will happen if I use this code in my program?
#define TRACE(n) printf("TRACE: %d\n", n)
a) Nothing it is good.
b) Code is wrong.
c) Error: macro replacement within a string literal
d) None
ANSWER: C
5.How can I print a '%' character in a printf format string?
a) Use “\%”
b) Use “/%”
c) None
d) Use “%%”
ANSWER: D
CONTINUE READING » main()
{
char *str[] = {“Frog”,”Do”,”Not”, “Die.”,”They”,”Croak!”};
printf(“%d %d”, Sizeof (str), sizeof (str[0]));
}
a) 3 12
b) 2 12
c) 12 3
d) 12 2
ANSWER: D
2.What would be the output of the following program?
main()
{
char str1[] = “Hello”;
char str2[] = “Hello”;
if(str1 == str2)
printf(“Equal”);
else
printf(“\nUnequal”);
}
a) Error.
b) Equal.
c) Unequal.
d) None.
ANSWER: C
3.Would the following Code give any error on compilation?
strcat (string,’!’);
a) Yes.
b) No.
ANSWER: A
4.What will happen if I use this code in my program?
#define TRACE(n) printf("TRACE: %d\n", n)
a) Nothing it is good.
b) Code is wrong.
c) Error: macro replacement within a string literal
d) None
ANSWER: C
5.How can I print a '%' character in a printf format string?
a) Use “\%”
b) Use “/%”
c) None
d) Use “%%”
ANSWER: D