C Language

Description: Test your C skill in programming language for mca entrance and campus placements by free online preparation and practice paper tests
Number of Questions: 11
Created by:
Tags: Basics C Skills Advanced C Skills C Skills Test Java Skill Test DBMS Oracle PHP Computer Application Placement Papers MCA Entrance BCA BSC Programming Fundamentals of Computer Programming AP General term of an Arithmetic Progression Odd One Out Classification
Attempted 0/11 Correct 0 Score 0

Which one of the following is valid for opening a read-only ASCII file?

  1. fileOpen (filenm, "r")

  2. fileOpen (filenm, "ra")

  3. fileOpen (filenm, "read")

  4. fopen (filenm, "read")

  5. fopen (filenm, "r")


Correct Option: E

f = fopen( filename, "r" ); Referring to the code above, what is the proper definition for the variable f?

  1. FILE f

  2. FILE *f

  3. int f

  4. struct FILE f

  5. char *f


Correct Option: B

If there is a need to see output as soon as possible, what function will force the output from the buffer into the output stream?

  1. flush()

  2. output()

  3. fflush()

  4. dump()

  5. write()


Correct Option: A

Short int x; /* assume x is 16 bits in size */, what is the maximum number that can be printed using printf(%d , x), assuming that x is initialized as shown above?

  1. 127

  2. 128

  3. 255

  4. 32, 767

  5. 65, 536


Correct Option: D

Which one of the following can be used to test arrays of primitive quantities for strict equality under Standard C?

  1. qsort()

  2. bcmp()

  3. memcmp()

  4. strxfrm()

  5. bsearch()


Correct Option: E

void crash (void) {
printf(got here); *((char *) 0) = 0; } The function crash(), defined above, triggers a fault in the memory management hardware for many architectures. Which one of the following explains why got here may not be printed before the crash?

  1. The C standard says that dereferencing a null pointer causes undefined behavior. This may explain why printf() apparently fails.

  2. If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs.

  3. printf() always buffers output until a new line character appears in the buffer. Since no newline was present in the format string, nothing is printed.

  4. There is insufficient information to determine why the output fails to appear. A broader context is required.

  5. printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.


Correct Option: B

char * dwarves [] = { Sleepy, Dopey Doc, Happy, Grumpy Sneezy, Bashful, }; How many elements does the array declared above contain? Assume the C compiler employed strictly complies with the requirements of Standard C.

  1. 4

  2. 5

  3. 6

  4. 7

  5. 8


Correct Option: B

char *buffer = 0123456789; char *ptr = buffer; ptr += 5; printf( %s, ptr ); printf( %s, buffer );
What will be printed when the sample code above is executed?

  1. 0123456789 56789

  2. 5123456789 5123456789

  3. 56789 56789

  4. 0123456789 0123456789

  5. 56789 0123456789


Correct Option: E

What number is equivalent to -4e3?

  1. -4000

  2. -400

  3. -40

  4. 004

  5. 0004


Correct Option: A

int debug (const char * fmt, ...) { extern FILE * logfile; va_list args; assert(fmt); args = va_arg(fmt, va_list); return vfprintf(logfile, fmt, args); } The function debug(), defined above, contains an error. Which one of the following describes it?

  1. The ellipsis is a throwback from K&R C. In accordance with Standard C, the declaration of args should be moved into the parameter list, and the K&R C macro va_arg() should be deleted from the code.

  2. vfprintf() does not conform to ISO 9899: 1990, and may not be portable.

  3. Library routines that accept argument lists cause a fault on receipt of an empty list. The argument list must be validated with va_null() before invoking vfprintf().

  4. The argument list args has been improperly initialized.

  5. Variadic functions are discontinued by Standard C; they are legacy constructs from K&R C, and no longer compile under modern compilers.


Correct Option: A

How does variable definition differ from variable declaration?

  1. Definition allocates storage for a variable, but declaration only informs the compiler as to the variable's type.

  2. Declaration allocates storage for a variable, but definition only informs the compiler as to the variable's type.

  3. Variables may be defined many times, but may be declared only once.

  4. Variable definition must precede variable declaration.

  5. There is no difference in C between variable declaration and variable definition.


Correct Option: C
- Hide questions