Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 43

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Hide Answer

Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4
B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Hide Answer

Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error
Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Show Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Hide Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?
A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Hide Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.
char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Show Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>
int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100.
Hide Answer

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Hide Answer

Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);
printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Hide Answer

Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!
B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Hide Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Hide Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Hide Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False
Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Show Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

}
A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100.

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Hide Answer

Q 2 - What is the output of the following program?

#include<stdio.h>
main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Hide Answer

Q 4 - What is the output of the following program?

#include<stdio.h>
main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Show Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);

A - Hello
B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Hide Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Hide Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Hide Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"
C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()

int y = 100;

const int x = y;
printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Show Answer
Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Show Answer
Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Hide Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);
}

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Hide Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure


Answer : C
Explanation
If var is a variable then &var is an address in memory.
Hide Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Hide Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;
}

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()
{

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Hide Answer

Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Show Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.


Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Hide Answer

Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Show Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()

#undef NULL

char *s = "Hello";
while(*s != NULL)

printf("%c", *s++);

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Hide Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables


B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Show Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Show Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");
ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?


#include<stdio.h>

int main()

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100.

Q 1 - What is the output of the below code snippet?

#include<stdio.h>
main()

for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error
Show Answer

Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.


Show Answer

Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Hide Answer

Q 5 - What is the output of the following program?

#include<stdio.h>

main()
{

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Show Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.
In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Show Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Show Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Hide Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>

int main ()
{

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);


return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100.

Q 1 - What is the output of the below code snippet?

#include<stdio.h>

main()

{
for()printf("Hello");

A - Infinite loop

B - Prints Hello once.

C - No output

D - Compile error

Answer : D
Explanation
Compiler error, semi colons need to appear though the expressions are optional for the
for loop.
Show Answer

Q 2 - What is the output of the following program?

#include<stdio.h>

main()

int i = 1;

while(i++<=5);

printf("%d ",i++);

A-4

B-6

C-26

D-24

Answer : B
Explanation
6, there is an empty statement following while.
Hide Answer

Q 3 - Following is the invalid inclusion of a file to the current program. Identify it.

A - #include <file>

B - #include file

C - #include < file

D - All of the above are invalid.

Answer : C
Explanation
option (a) & (b) are valid. There is no such syntax or provision as in option (c).
Show Answer

Q 4 - What is the output of the following program?

#include<stdio.h>

main()

fprintf(stdout,"Hello, World!");

A - Hello, World!

B - No output

C - Compile error

D - Runtime error

Answer : A
Explanation
stdout is the identifier declared in the header file stdio.h which is connected to standard
output device (monitor).
Hide Answer

Q 5 - What is the output of the following program?


#include<stdio.h>

main()

#undef NULL

char *s = "Hello";

while(*s != NULL)

printf("%c", *s++);

A - Hello

B - Compile error: there is no macro called undef

C - Compile error: improper place of #undef

D - Compile error: NULL is undeclared.

Answer : D
Explanation
NULL is equivalent to \0 in value. Statement *s++ prints the character first and
increments the address later.
Show Answer

Q 6 - In Windows & Linux, how many bytes exist for near, far and huge pointers?

A - Near: 1, far: 4, huge: 7

B - near: 4, far: 4, huge: 4

C - near: 0, far: 4, huge: 4

D - near: 4, far: 5, huge: 6

Answer : B
Explanation
In DOS, numbers of byte exist for near pointer = 2, far pointer = 4 and huge pointer =
4.

In Windows and Linux, numbers of byte exist for near pointer = 4, far pointer =
4 and huge pointer = 4.
Hide Answer

Q 7 - What is a pointer?

A - A keyword used to create variables

B - A variable used to store address of an instruction

C - A variable used to store address of other variable

D - A variable used to store address of a structure

Answer : C
Explanation
If var is a variable then &var is an address in memory.
Show Answer

Q 8 - fgets() function is safer than gets() because in fgets() function you can specify the
size of the buffer into which the supplied string will be stored.

A - True

D - False

Answer : A
Explanation
Both functions retrive and store a string from console or file, but fgets() functions are
more safer to use then gets() because gets() doesn't facilitate to detail the length of the
buffer to store the string in and fgets() facilitates to specify a maximum string length.

char *fgets(char *s, int size, FILE *stream);

char *gets(char *s);

Hide Answer

Q 9 - Which files will get closed through the fclose() in the following program?

#include<stdio.h>
int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");

ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

A - "ABC"

B - "ACD"

C - "ADF"

D - Return error

Answer : D
Explanation
The syntax of fclose() function is wrong; it should be int fclose(FILE *stream); closes
the stream. Here, fclose(fp, fs, ft); is using separator(,) which returns error by saying
that extra parameter in call to fclose() function.

#include<stdio.h>

int main ()

FILE *fs, *ft, *fp;

fp = fopen("ABC", "r");

fs = fopen("ACD", "r");
ft = fopen("ADF", "r");

fclose(fp, fs, ft);

return 0;

Hide Answer

Q 10 - In the given below code, what will be the value of a variable x?

#include<stdio.h>

int main()

int y = 100;

const int x = y;

printf("%d\n", x);

return 0;

A - 100

B-0

C - Print x

D - Return Error

Answer : A
Explanation
Although, integer y = 100; and constant integer x is equal to y. here in the given above
program we have to print the x value, so that it will be 100

You might also like