C/C /C Programming - MCQ Questions Set 4 Sample Test,Sample questions

Question:
 For a typical program, the input is taken using _________

1.scanf

2.Files

3.Command-line

4.All of the mentioned


Question:
 The type va_list in an argument list is used _____

1.To declare a variable that will refer to each argument in turn;

2.For cleanup

3.To create a list

4.There is no such type


Question:
 typedef int (*PFI)(char *, char *)creates _________

1.type PFI, for pointer to function (of two char * arguments) returning int

2. error

3.type PFI, function (of two char * arguments) returning int

4.type PFI, for pointer


Question:
Bit fields can only be declared as part of a structure.

1.FALSE

2. true

3.Nothing

4.Varies


Question:
Each call of va_arg ____

1.Returns one argument

2.Steps va_list variable to the next

3.Returns one argument & Steps va_list variable to the next

4.None of the mentioned


Question:
Escape sequences are prefixed with ____

1.%

2./

3.”

4.None of the mentioned


Question:
For binary files, a ___ must be appended to the mode string.

1.Nothing

2. “b”

3. “binary”

4.“01”


Question:
In a variable length argument function, the declaration “…” can _____

1.Appear anywhere in the function declaration

2. Only appear at the end of an argument list

3.Nothing

4.None of the mentioned


Question:
In C language, FILE is of which data type?

1. int

2.char *

3. struct

4.None of the mentioned


Question:
Presence of code like “s.t.b = 10” indicates ____

1.Syntax Error

2.Structure

3.double data type

4.An ordinary variable name


Question:
Members of a union are accessed as______

1. union-name.member

2.union-pointer->member

3.both union-name.member & union-pointer->member

4.none of the mentioned


Question:
Presence of loop in a linked list can be tested by ________

1.Traveling the list, if NULL is encountered no loop exists

2.Comparing the address of nodes by address of every other node

3.Comparing the the value stored in a node by a value in every other node

4.None of the mentioned


Question:
putchar(c) function/macro always outputs character c to the _____

1.screen

2.standard output

3.depends on the compiler

4.depends on the standard


Question:
The size of a union is determined by the size of the ______

1.First member in the union

2.Last member in the union

3.Biggest member in the union

4.Sum of the sizes of all members


Question:
The statement prog < infile causes _____

1.prog to read characters from infile

2. prog to write characters to infile

3. infile to read characters from prog instead

4.nothing


Question:
The syntax to print a % using printf statement can be done by ____

1. %

2. \%

3. ‘%’

4.%%


Question:
What are the first and second arguments of fopen?

1.A character string containing the name of the file & the second argument is the mode

2.A character string containing the name of the user & the second argument is the mode

3.A character string containing file pointer & the second argument is the mode

4.None of the mentioned


Question:
What does the following command line signify?  prog1|prog2

1.It runs prog1 first, prog2 second

2. It runs prog2 first, prog1 second

3.It runs both the programs, pipes output of prog1 to input of prog2

4.It runs both the programs, pipes output of prog2 to input of prog1


Question:
What does the following segment of C code do? fprintf(fp, "Copying!");

1.It writes “Copying!” into the file pointed by fp

2.It reads “Copying!” from the file and prints on display

3.It writes as well as reads “Copying!” to and from the file and prints it

4.None of the mentioned


Question:
What is FILE reserved word?

1.A structure tag declared in stdio.h

2.One of the basic data types in c

3.Pointer to the structure defined in stdio.h

4.It is a type name defined in stdio.h


Question:
What is meant by ‘a’ in the following C operation?   fp = fopen("Random.txt", "a");

1.Attach

2.Append

3.Apprehend

4.Add


Question:
What is the correct syntax to declare a function foo() which receives an array of structure in function?

1.void foo(struct *var);

2.void foo(struct *var[]);

3.void foo(struct var);

4.none of the mentioned


Question:
What is the default return-type of getchar()?

1. char

2.int

3.char *

4.reading character doesn’t require a return-type


Question:
What is the difference between %e and %g?

1.%e output formatting depends on the argument and %g always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional

2.%e always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional and output formatting depends on the argument

3.No differences

4.Depends on the standard


Question:
What is the purpose of sprintf?

1. It prints the data into stdout

2.It writes the formatted data into a string

3. It writes the formatted data into a file

4.None of the mentioned


Question:
What is the return value of getc()?

1.The next character from the stream is not referred by file pointer

2.EOF for end of file or error

3.Nothing

4.None of the mentioned


Question:
What is the return value of putchar()?

1.The character written

2.EOF if an error occurs

3.Nothing

4.Both character written & EOF if an error occurs


Question:
What is the use of getchar()?

1. The next input character each time it is called

2.EOF when it encounters end of file

3.The next input character each time it is called EOF when it encounters end of file

4.None of the mentioned


Question:
What is the value of EOF?

1.-1

2.0

3.1

4.10


Question:
What is typedef declaration?

1.Does not create a new type

2.It merely adds a new name for some existing type

3.Does not create a new type, It merely adds a new name for some existing type

4.None of the mentioned


Question:
What will fopen will return, if there is any error while opening a file?

1.Nothing

2.EOF

3.NULL

4.Depends on compiler


Question:
When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?

1.Standard input

2.Standard output

3. Standard error

4.All of the mentioned


Question:
Which among the following is the odd one out?

1.printf

2.fprintf

3.putchar

4.scanf


Question:
Which header file includes a function for variable number of arguments?

1.stdlib.h

2. stdarg.h

3.ctype.h

4.both stdlib.h and stdarg.h


Question:
Which is true about function tolower?

1.The function tolower is defined in <ctype.h>

2.Converts an uppercase letter to lowercase

3.Returns other characters untouched

4. None of the mentioned


Question:
Which of the following data types are accepted while declaring bit-fields?

1.char

2.float

3.double

4.none of the mentioned


Question:
Which of the following data-types are promoted when used as a parameter for an ellipsis?

1.char

2.short

3. int

4.none of the mentioned


Question:
Which of the following fopen() statements are illegal?

1.fp = fopen(“abc.txt”, “r”);

2.fp = fopen(“/home/user1/abc.txt”, “w”);

3.fp = fopen(“abc”, “w”);

4.none of the mentioned


Question:
Which of the following function with ellipsis are illegal?

1.void func(…);

2.void func(int, …);

3.void func(int, int, …);

4.none of the mentioned


Question:
Which of the following is false about typedef?

1.typedef follow scope rules

2.typedef defined substitutes can be redefined again. (Eg: typedef char a; typedef int a;)

3.You cannot typedef a typedef with other term

4.All of the mentioned


Question:
Which of the following is not allowed?

1.Arrays of bit fields

2.Pointers to bit fields

3. Functions returning bit fields

4.None of the mentioned


Question:
Which of the following macro extracts an argument from the variable argument list (ie ellipsis) and advance the pointer to the next argument?

1.va_list

2.va_arg

3. va_end

4.va_start


Question:
Which of the following may create problem in the typedef program?

1.;

2.printf/scanf

3.Arithmetic operators

4. All of the mentioned


Question:
Which of the following mode argument is used to truncate?

1.a

2.f

3.w

4.t


Question:
Which of the following reduces the size of a structure?

1.union

2.bit-fields

3.malloc

4.none of the mentioned


Question:
Which of the following statement is true?

1.The symbolic constant EOF is defined in <stdio.h>

2.The value is -1

3.The symbolic constant EOF is defined in <stdio.h> & value is -1

4.Only value is -1


Question:
Which of the following uses structure?

1.Array of structures

2.Linked Lists

3.Binary Tree

4.All of the mentioned


Question:
Which of the given option is the correct method for initialization?  typedef char *string;

1.*string *p = “Hello”;

2.string p = “Hello”;

3.*string p = ‘A’;

4.Not more than one space should be given when using typedef


Question:
Which option should be selected to work the following C expression?  string p = "HELLO";

1.typedef char [] string;

2.typedef char *string;

3. typedef char [] string; and typedef char *string;

4.Such expression cannot be generated in C


Question:
Which type of files can’t be opened using fopen()?

1..txt

2. .bin

3..c

4.none of the mentioned


More MCQS

  1. C++ Programming MCQS Set-1
  2. C++ Multiple Choice Questions Set-1
  3. C++ Multiple Choice Questions Set-2
  4. C++ Programming MCQS Set-2
  5. C++ Programming MCQS Set-3
  6. C++ Programming MCQS Set-4
  7. C++ (CPP) MCQ Question with Answer
  8. Advanced c++ multiple choice question(MCQS)
  9. OOPS Quiz Questions and Answers(MCQS)
  10. C Programming - MCQ Questions Set 1
  11. C Programming - MCQ Questions Set 2
  12. C Programming - MCQ Questions Set 3
  13. C Programming - MCQ Questions Set 4
  14. C Programming - MCQ Questions Set 5
  15. C++ programming language MCQ Questions Set 1
  16. C++ programming language MCQ Questions Set 2
  17. C++ programming language MCQ Questions Set 3
  18. C++ programming language MCQ Questions Set 4
  19. C++ programming language MCQ Questions Set 5
  20. C++ Programming -Constructors and Destructors
  21. C++ Programming -OOPS Concepts
  22. C++ Programming - References
  23. C++ Programming - Functions
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!