0% found this document useful (0 votes)
27 views

MCQ - C Programming II

Uploaded by

sankalpakunwar2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

MCQ - C Programming II

Uploaded by

sankalpakunwar2
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 148

C Programming II

Question - 1

Which of the following are themselves a collection of different data types.

a) String
b) Structure
c) char
d) All of the mentioned

Answer Key: B
Question - 2

Which of the following cannot be a structure member?

a) Another Structure
b) Function
c) Array
d) None of the variable name

Answer Key: B
Question - 3

Presence of code like “s.t.b=10” indicates ______

a) Syntax Error
b) Structure
c) Double data type
d) An ordinary variable name

Answer Key: B
Question - 4

Which of the following is a correct format for declaration of function?

a) return-type function name (argument type);


b) return-type function name (argument type ) {}
c) return-type (argument type) function- name;
d) all of the above

Answer Key: A
Question - 5

Which of the following function declaration is illegal ?

a) int 1bhk (int)-


b) int 1 bhk(int a);
c) int 2bhk (int*,int[];
d) All of the mentioned

Answer Key: D
Question - 6

Which among the following is the odd one out?

a) Printf
b) fprintf
c) putcher
d) scanf

Answer Key: D
Question - 7

For a typical program, the input is taken using _____

a) scanf
b) Files
c) Command -line
d) All of the mentioned

Answer Key: A
Question - 8

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

a) Nothing
b) EOF
c) NULL
d) Depends of the mentioned

Answer Key: C
Question - 9

When a C program is started, O.S environment is responsible for


opening file and providing pointed for that file?

a) Standard input
b) Standard output
c) Standard error
d) All of the mentioned

Answer Key: D
Question - 10

What is meant by ‘a’ in the following C Operation?

a) Attach
b) Append
c) Apprehend
d) Add

Answer Key: B
Question - 11

Choose correct statement about functions in C Language.

a) A Function is a group of c statement which can be reused any number of times.


b) Every Function has a return type.
c) Every Function may not return a value.
d) All of the above.

Answer Key: D
Question - 12

A function which calls itself is called a ___ function.

a) Sell Function
b) Auto Function
c) Recursive Function
d) Static Function

Answer Key: D
Question - 13

What are types of functions in C Language?

a) Library Functions
b) User Defined Functions
c) Both a and b
d) None of the above

Answer Key: D
Question - 14

What is the limit for number of functions in a C Program?

a) 1
b) 16
c) 32
d) None of the above

Answer Key: D
Question - 15

A C function return ____ value.

a) 0
b) 1
c) 0 or 1
d) More than 1

Answer Key: C
Question - 16

Every C Program should contain which function ?

a) Print()
b) show()
c) scanf ()
d) main()

Answer Key: D
Question - 17

What is the minimum number of functions to be present in a C


Program?

a) 1
b) 2
c) 3
d) 4

Answer Key: A
Question - 18

Arguments passed to a function in C Language are called ___


arguments.

a) Formal arguments
b) Actual Arguments
c) Definite Arguments
d) Ideal Arguments

Answer Key: B
Question - 19

Arguments received by a function in C Language are called ___


arguments

a) Definite Arguments
b) Formal arguments
c) Actual Arguments
d) Ideal Arguments

Answer Key: B
Question - 20

What is the C Keyword that must be used to achieve expected result


using Recursion?

a) printf
b) scanf
c) void
d) return

Answer Key: D
Question - 21

Default storage class is _____.

a) auto
b) static
c) extern
d) register

Answer Key: A
Question - 22

Default value of automatic variable is __________.

a) 0
b) 1
c) garbage
d) None of the above

Answer Key: C
Question - 23

Default value of external variable is __________.

a) 0
b) 1
c) garbage
d) None of the above

Answer Key: A
Question - 24

Which of the variable will not get its space from RAM?

a) Auto
b) extern
c) static
d) register

Answer Key: D
Question - 25

Which among the following is a Local Variable?

a) register
b) auto
c) static
d) extern

Answer Key: B
Question - 26

Which among the following is a Global Variable?

a) auto
b) register
c) static
d) extern

Answer Key: D
Question - 27

Structure is a collection of _____

a) Homogenous data types


b) Heterogeneous data types
c) Both A and B
d) None of the above

Answer Key: B
Question - 28

_________ cannot be the member of structure.

a) Array
b) Structure
c) Function
d) Pointer

Answer Key: C
Question - 29

Size of union is determined by the size of

a) First member
b) Largest member
c) Sum of size of all member
c) None of the above

Answer Key: B
Question - 30

_______ operator is used to access member of structure.

a)
b) ->
c) Both A and B
d) d) None of the above

Answer Key: C
Question - 31

______ is used to define custom data types in C.

a) Array
b) Function
c) Pointer
d) structure

Answer Key: D
Question - 32

Address operator in C is _______.

a) &
b) b) *
c) []
d) ->

Answer Key: A
Question - 33

Indirection operator in C is _______ .

a) &
b) b) *
c) []
d) ->

Answer Key: B
Question - 34

If a is a variable and x is an array, then which is not a valid in C?

a) &a
b) &x[5]
c) &(a+2)
d) None of the above

Answer Key: C
Question - 35

If m is an array, then which is true?

a) m is constant
b) Value of m is always & [0].
c) Both a & b
d) Only A.

Answer Key: C
Question - 36

Which is true?

a) Two pointers can be added


b) Two pointers can be subtracted if the points to elements of same array.
c) Two pointers can be multiplied.
d) All above statements are false.

Answer Key: B
Question - 37

Passing address as actual argument is _______

a) Call by value
b) call by reference
c) Both a and b
d) None of the above

Answer Key: B
Question - 38

Data file is stored in _____

a) RAM
b) ROM
c) Hard disk
d) All of the above

Answer Key: C
Question - 39
What is the output of this C code?
#include <stdio.h>
main()
{
int n = 0, m = 0;
if (n > 0)
if (m > 0)
printf("True");
else
printf("False");
}

a) True
b) False
c) No Output will be printed
d) Run Time Error Answer Key: C
Question - 40

What will be the data type returned for the following C function?
#include <stdio.h>
int func()
{
return (double)(char)5.0;
}

a) char
b) int
c) double
d) multiple type-casting

Answer Key: B
Question - 41

Library function used to set the file pointer to desired location is _____

a) rewind
b) tell
c) fseek
d) remove

Answer Key: C
Question - 42

____ function used to write block of data in file.

a) fputs
b) fscanf
c) fwrite
d) fread

Answer Key: C
Question - 43

____ file store the data in same format as in memory.

a) Text
b) Binary
c) Both A & B
d) None of the Above

Answer Key: B
Question - 44

Function not used in random access of file is ______

a) fseek
b) remove
c) rewind
d) None of the above

Answer Key: B
Question - 45

Which is not a file input function?

a) getw
b) fwrite
c) fcanf
d) None of the above

Answer Key: D
Question - 46

____is a reserved word that has standard and predefined meanings in C.

a) Variable
b) identifier
c) Keyboard
d) None of the above

Answer Key: C
Question - 47

______________is a quantity that doesn’t change during program


execution

a) Variable
b) Constant
c) data type
d) None of the above

Answer Key: B
Question - 48
___________is a symbolic name, which is used to store different types
of data in the computer’s memory and may change during the program
execution.

a) Variable
b) Constant
c) identifier
d) None of the above

Answer Key: A
Question - 49

________is a symbol that instructs C to perform some operation or


action on one or more operands.

a) Operand
b) Operation
c) Operator
d) None of the above

Answer Key: C
Question - 50

__________is something that an operator acts on.

a) Operand
b) Operation
c) Operator
d) None of the above

Answer Key: A
Question - 51

_____________can be used to output data of different types of


different formats.

a) print()
b) Scanf()
c) variable
d) None of the above

Answer Key: A
Question - 52

__________can read all the built-in data types and automatically


convert numbers into the proper internal format.

a) print()
b) scanf()
c) variable
d) None of the above

Answer Key: B
Question - 53

__________is an operation that repeats the execution of a statement


until a certain condition is satisfied.

a) Looping
b) variable
c) Constant
d) None of the above

Answer Key: A
Question - 54

__________is a collection of variables of the same type represented by a


common name.

a) Structure
b) array
c) Function
d) None of the above

Answer Key: B
Question - 55

___________is a self-contained program segment or the block of


statements that perform some specific, well-defined task.

a) Array
b) function
c) Structure
d) None of the above

Answer Key: B
Question - 56

Choose correct statement about functions in C Language.

a) A function is a group of c statement which can be reused any number of times.


b) Every function has a return type.
c) Every function may no may not return a value.
d) All of the above

Answer Key: D
Question - 57

Choose a correct statement about C language functions.

a) function name cannot be same as a predefined C keyword.


b) A function name can start with an Underscore (_) or A to Z or a to z.
c) Default return type of any function is an Integer.
d) All of the above

Answer Key: D
Question - 58

A function which calls itself is called a______function.

a) Self – function
b) Auto - function
c) Recursive Function
d) Static function

Answer Key: C
Question - 59

What is the meaning of the following C statement?


printf(“%10s”, state);

a) 10 spaces before the string state is printed


b) Print empty spaces if the string state is less than 10 characters
c) Print the last 10 characters of the string
d) None of the mentioned

Answer Key: B
Question - 60

What is the meaning of the following C statement?


printf(“%10s”, state);

a) 10 spaces before the string state is printed


b) Print empty spaces if the string state is less than 10 characters
c) Print the last 10 characters of the string
d) None of the mentioned

Answer Key: B
Question - 61

What is the minimum number of functions to be present in a C Program?

a) 1
b) 2
c) 3
d) 4

Answer Key: A
Question - 62

What is the minimum number of functions to be present in a C Program?

a) 1
b) 2
c) 3
d) 4

Answer Key: A
Question - 63

Arguments passed to a function in C language are


called_____arguments.

a) Formal arguments
b) Actual arguments
c) Definite arguments
d) Ideal arguments

Answer Key: B
Question - 64

Comment on the following pointer declaration?


int *ptr,p;

a) ptr it’s a pointer to integer, p is not.


b) ptr and p, both are pointers to integer.
c) ptr is pointer to integer , p may or may not be .
d_ ptr and p both are not pointers to integer.

Answer Key: A
Question - 65

Comment on the following pointer declaration?


int *ptr,p;

a) ptr it’s a pointer to integer, p is not.


b) ptr and p, both are pointers to integer.
c) ptr is pointer to integer , p may or may not be .
d)ptr and p both are not pointers to integer.

Answer Key: A
Question - 66

What is the size of a C structure?

a) C structure is always 128 bytes.


b) Size of C structure is the total bytes of all elements of structure.
c) Size of C structure is the size of largest elements.
d) None of the above.

Answer Key: B
Question - 67

What is the size of a C structure?

a) C structure is always 128 bytes.


b) Size of C structure is the total bytes of all elements of structure.
c) Size of C structure is the size of largest elements.
d) None of the above.

Answer Key: B
Question - 68

Which of the following are themselves a collection of different data types?

a) string
b) Struct
c) char.
d) All of the mentioned

Answer Key: B
Question - 69

What are the types of data allowed inside a structure?

a) int, float, double, long, double.


b) chair, enum, union
c) Pointers and same structure type members.
d) All of the above

Answer Key: D
Question - 70

What are the types of data allowed inside a structure?

a) int, float, double, long, double.


b) chair, enum, union
c) Pointers and same structure type members.
d) All of the above

Answer Key: D
Question - 71

Members of a union are accessed as______

a) union-name.member
b) union-pointer->member
c) a) and b)
d) none of the mentioned

Answer Key: C
Question - 72

What function is used as a formatted output file function?

a) print()
b) fprint()
c) puts ()
d) fputs()

Answer Key: B
Question - 73

A made which is used to open an existing file foe both reading and writing…

a) “W”
b) “W+”
c) “A+”
d) “R+”

Answer Key: D
Question - 74

What in the output of C program?

a) “W”
b) “W+”
c) “A+”
d) “R+”

Answer Key: D
Question - 75

Who is the father of C language?

a) Steve Jobs
b) James Gosling
c) Dennis MacAlistair Ritchie
d) Rasmus Lerdorf

Answer Key: C
Question - 76

Which of the following is not a valid C variable name?

a) int number;
b) float rate;
c) int variable_count;
d) int $main;

Answer Key: D
Question - 77

Which of the following is true for variable names in C?

a) They can contain alphanumeric characters as well as special characters


b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length

Answer Key: C
Question - 78

Which is valid C expression?

a) int my_num = 100,000;


b) int my_num = 100000;
c) int my num = 1000;
d) int $my_num = 10000;

Answer Key: B
Question - 79

Which of the following cannot be a variable name in C?

a) volatile
b) true
c) friend
d) export

Answer Key: A
Question - 80

What is short int in C programming?

a) The basic data type of C


b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the mentioned

Answer Key: C
Question - 81

Which of the following declaration is not supported by C language?

a) String str;
b) b) char *str;
c) c) float str = 3e2;
d) d) a) and c)

Answer Key: A
Question - 82

What is an example of iteration in C?

a) for
b) while
c) do-while
d) all of the mentioned

Answer Key: D
Question - 83

Functions in C Language are always _________

a) Internal
b) External
c) Both Internal and External
d) External and Internal are not valid terms for functions

Answer Key: B
Question - 84

What is #include <stdio.h>?

a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned

Answer Key: A
Question - 85

Which of the following are C preprocessors?

a) #ifdef
b) #define
c) #endif
d) all of the mentioned

Answer Key: D
Question - 86

The C-preprocessors are specified with ______ symbol.

a) #
b) $
c) ” ”
d) &

Answer Key: A
Question - 87

How many number of pointer (*) does C have against a pointer variable
declaration?

a) 7
b) 127
c) 255
d) No limits

Answer Key: D
Question - 88

In C language, FILE is of which data type?

a) int
b) char *
c) struct
d) None of the mentioned

Answer Key: C
Question - 89

What is the sizeof(char) in a 32-bit C compiler?

a) 1 bit
b) 2 bits
c) 1 Byte
d) 2 Bytes

Answer Key: C
Question - 90

Which of the following is not an operator in C?

a) ,
b) sizeof()
c) c) ~
d) d) None of the mentioned

Answer Key: D
Question - 91

scanf() is a predefined function in______header file.

a) stdlib. h
b) ctype. h
c) stdio. h
d) stdarg. h

Answer Key: C
Question - 92

What is meant by ‘a’ in the following C operation?


fp = fopen("Random.txt", "a");

a) Attach
b) Append
c) Apprehend
d) Add

Answer Key: B
Question - 93

What will be the output of the following C code?


#include <stdio.h>
int main()
{
int y = 10000;
int y = 34;
printf("Hello World! %d\n", y);
return 0;
}
a) Compile time error
b) Hello World! 34
c) Hello World! 1000
d) Hello World! followed by a junk value
Answer Key: A
Question - 94

What will happen if the following C code is executed?


#include <stdio.h>
int main()
{
int main = 3;
printf("%d", main);
return 0;
}
a) It will cause a compile-time error
b) It will cause a run-time error
c) It will run without any error and prints 3
d) It will experience infinite looping
Answer Key: C
Question - 95

What will be the output of the following C code?


#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned
Answer Key: B
Question - 96
What will be the output of the following C code on a 64 bit machine?
#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf("%d", sizeof(s));
return 0;
}

a) 8
b) 5
c) 9
Answer Key: D
d) 4
Question - 97

What will be the final value of x in the following C code?


#include <stdio.h>
void main()
{
int x = 5 * 9 / 3 + 9;
}

a) 3.75
b) Depends on compiler
c) 24
d) 3

Answer Key: C
Question - 98

What will be the output of the following C code? (Initial values: x= 7, y = 8)


#include <stdio.h>
void main()
{
float x;
int y;
printf("enter two numbers \n");
scanf("%f %f", &x, &y);
printf("%f, %d", x, y);
}

a) 7.000000, 7
b) Run time errorc) 7.000000, junk
d) Varies

Answer Key: C
Question - 99

What will be the output of the following C code snippet?


#include <stdio.h>
void main()
{
1 < 2 ? return 1: return 2;
}
a) returns 1
b) returns 2
c) Varies
d) Compile time error

Answer Key: D
Question - 100

Comment on the following C statement.


n = 1;
printf("%d, %dn", 3*n, n++);

a)Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent

Answer Key: D
Question - 101
How many times i value is checked in the following C program?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
}

a)Output will be 3, 2
b) Output will be 3, 1
c) Output will be 6, 1
d) Output is compiler dependent

Answer Key: C
Question - 102

Array index always start with______

a) 0
b) 1
c) 2
d) 4

Answer Key: A
Question - 103

The_____storage class is used to transmit information across the blocks


and functions.

a) auto
b) extern
c) static
d) register

Answer Key: D
Question - 104

Which of the storage class is speed?

a) auto
b) extern
c) static
d) register

Answer Key: B
Question - 105

In C, what is the meaning of following function prototype with empty


parameter list:
void fun( )
{
/* .... */
}

a) Function can only be called without any parameter


b) Function can be called with any number of parameters of any types
c) Function can be called with any number of integer parameters.
d) Function can be called with one integer parameter.

Answer Key: B
Question - 106

It is necessary to declare the type of a function in the calling program if


the function

a) Returns an Integer
b) Returns a non-integer value
c) Is not defined in the same file
d) None of these

Answer Key: B
Question - 107

A function that is prototype as


int calculate(int num);
may:

a) Receive an integer variable named num from the main () program


b) Receive any integer variable from the main() program
c) Either a) or b)
d) None of these

Answer Key: C
Question - 108

The declaration:
void function1(int)
indicates the function1 is a function which

a) Has no arguments
b) Returns nothing
c) Both a) and b)
d) None of these

Answer Key: B
Question - 109

The function fprintf is used in a program

a) When too many printf calls have been alrady used in the program
b) In place of printf, since printf uses more memory
c) When output i to be printed on to a file
d) All of above

Answer Key: C
Question - 110

In C, what is a function primarily used for?

a) Decision making
b) Variable declaration
c) Printing Output
d) Code reusability

Answer Key: D
Question - 111

In C, how are function arguments passed by default?

a) By value
b) By reference
c) By pointer
c) By address

Answer Key: A
Question - 112

What is the correct way to declare a function in C that takes no


arguments and returns an integer?

a) int func();
b) func(int);
c) func();
d) int func(int);

Answer Key: C
Question - 113

In C, what is the purpose of the 'return' statement in a function?

a) To declare the function's return type


b) To exit the program
c) To return a value for the function
d) To define a function

Answer Key: C
Question - 114

What is a function's return type in C if it does not return any value?

a) int
b) void
c) float
d) char

Answer Key: D
Question - 115

What is a function parameter in C?

a) A value passed to a function when it's called


b) A variable declared within a function
c) A reserved keyword
d) A global variable

Answer Key: A
Question - 116

What is the keyword used to define a structure in C?

a) struct
b) record
c) class
d) object

Answer Key: A
Question - 117

In a structure, what are the members also known as?

a) variables
b) properties
c) objects
d) elements

Answer Key: A
Question - 118

How do you access a member of a structure?

a) &
b) ::
c) ,
d) .

Answer Key: D
Question - 119

What is the keyword used to define a union in C?

a) struct
b) union
c) class
d) typedef

Answer Key: B
Question - 120

How is the size of a structure determined in C?

a) Total size of members


b) Largest size of member
c) Smallest size of member
d) Number of Members

Answer Key: B
Question - 121

How is the size of a union determined in C?

a) Total size of members


b) Largest size of member
c) Smallest size of member
d) Number of Members

Answer Key: A
Question - 122

Which of the following operators can be applied on structure variables?

a) Equality comparison (==)


b) Assignment (=)
c) Both of the above
d) None of the above

Answer Key: C
Question - 123
What will be output?
union test
{
int x;
char arr[8];
int y;
};

int main()
{
printf("%d", sizeof(union test));
return 0;
}

a) 12
b) 16
c) 8
Answer Key: C
d) Compile Error
Question - 124

Which of the following is a collection of different data type?

a) String
b) Array
c) Structure
d) Files

Answer Key: A
Question - 125

Elements of structures is/ are also known as:

a) fields
b) members
c) components
d) All of the above

Answer Key: D
Question - 126

Define new data type equivalent to the existing system data type using
the ______ statement.

a) typedef
b) struct
c) array
d) union

Answer Key: A
Question - 127

A point that will point to an integer data.

a) int *p
b) int *p[void]
c) int *p[char *a]
d) int *p[10]

Answer Key: A
Question - 128

P is a function that returns a pointer 0 an integer data.

a) int *p
b) int *p[void]
c) int *p[char *a]
d) int *p[10]

Answer Key: B
Question - 129

P is 10 element array of pointers to integer data.

a) int *p
b) int *p[void]
c) int *p[char *a]
d) int *p[10]

Answer Key: D
Question - 130

P is a function that accepts an argument, which is a pointer to a


character and return a pointer to an integer data.

a) int *p
b) int *p[void]
c) int *p[char *a]
d) int *p[10]

Answer Key: C
Question - 131

Used for opening the file for both reading and writing. The file must
already exist before performing the operation.

a) a+
b) r+
c) w+
d) o+

Answer Key: B
Question - 132

The _____ function lets us move the pointer from one record to another.

a) move ( )
b) cut( )
d) rewind( )
d) fseek( )

Answer Key: D
Question - 133

In C a pointer variable to an integer can be created by the declaration.

a) int p*;
b) int *p;
c) int +p;
d) int $p;

Answer Key: B
Question - 134

A pointer variable can be

a) Passed to a function
b) Changed within function
c) Returned by a function
d) Can be assigned integer

Answer Key: C
Question - 135

What will be the output of the following code?

a) 24
b) 34
c) 22
d) 23

Answer Key: D
Question - 136

Which of the following statements correct about k used in the below


statement?
char ****k;

a) k is a pointer to a pointer to a pointer to a char


b) k is a pointer to a pointer to a pointer to a pointer to a char
c) k is a pointer to a char pointer
d) k is a pointer to a pointer to a char

Answer Key: B
Question - 137

Address stored in the pointer variable is of type _______.

a) Integer
b) Float
c) Array
d) Character

Answer Key: A
Question - 138

What does this declaration means -


int (*p)[5];

a) p is one dimensional array of size 5, of pointers to integers


b) p is a pointer to a 5 elements integer array
c) The same as int *p[
d) None of these

Answer Key: B
Question - 139

Which of the following is the correct ways of declaring a float pointer?

a) float ptr;
b) float *ptr;
c) *float ptr;
d) None of the above

Answer Key: B
Question - 140

A mode which is used to open an existing file for both reading and
writing ______

a) ”W”
b) ”W+”
c) ”R+”
d) ”A+”

Answer Key: C
Question - 141

Select a function which is used to write a string to a file

a) pits()
b) putc()
c) fputs()
d) fgets()

Answer Key: C
Question - 142

Select a function which is used to read a single character from a file at a


time?

a) fscanf()
b) getch()
c) fgetc()
d) fgets()

Answer Key: C
Question - 143

Select a function which is used as a formatted output file function


______

a) printf()
b) fprintf()
c) puts()
d) fputs()

Answer Key: B
Question - 144

Select a function which is used as a formatted output file function


______

a) printf()
b) fprintf()
c) puts()
d) fputs()

Answer Key: B
Question - 145

Select a program which get input data from datafile and also send output
into datafile ,it is called _____

a) files
b) file processing
c) data files
d) file handling

Answer Key: D
Question - 146

Select text file in which data is stored in ________

a) ASCII code
b) Binary code
c) Octal code
d) Text code

Answer Key: A
Question - 147

Select text file in which number will take

a) 2 bytes
b) 4 bytes
c) 3 bytes
d) 8 bytes

Answer Key: B

You might also like