100 multiple choice questions in c programming with answers

 


Q 1 - choose  the correct function which can return a reminder by dividing -10.0/3.0?


A - rem = mod(-10.0, 3.0);
B - rem = fmod(-10.0, 3.0);
C - rem = modf(-10.0, 3.0);
D - Division of floating-point values can’t return reminder

Q 2 - How to round-off a value “5.77” to 6.0?

A - ceil(5.77)
B - round-off(5.77)
C - round-up(5.77)
D - floor(5.77)

Q 3 - The prototype of a function can be used to,

A - Define a function
B - Declare a function
C - Erase a function
D - None of the above

Q 4 - int fun(); - The declaration indicates the presence of a function defined inside the current module or in the same file.

A - True
B - False

Q 5 - The types of linkages are,

A - Internal linkage and External linkage
B - Internal linkage, External linkage, and None linkage
C - Internal linkage and None linkage
D - External linkage and None linkage

Q 6 - A Variable name in C includes which special symbols?

A - * (asterisk)
B - # (Hash)
C - + (Addition)
D - _ (underscore)

Q 7 - How do you specify double constant 3.14 as a long double?

A - By using LD after 3.14
B - By using L after 3.14
C - By using DL after 3.14
D - By using LF after 3.14

Q 8 - In normalized form, if the binary equivalent of 5.375 is “0100 0000 1010 1100 0000 0000 0000 0000” then what will be the output of the program in the Intel core machine?

#include<stdio.h>
#include<math.h>
int main ()
{
   float a = 5.375;
   char *p;
   int i;
   p = (char*)&a;
   for(i=0; i <= 3; i++)
      printf("%02x\n", (unsigned char)p[i]);
   return 0;
}

A - 40 AC 00 00
B - 00 00 AC 40
C - 00 00 CA 04
D - None

Q 9 - Which header statement is missing in the given below program to get the desired output?

#include<stdio.h>
#include<math.h>
int main ()
{
   double x = 1234321;
   double result = sqrt(x);
   printf("The square root of %.2lf is %.2lf\n", x, result);
   return 0;
}

A - #include<defs.h>
B - #include<math.h>
C - #include<stdlib.h>
D - Above program is absolutely correct to give the desired result

Q 10 - In the standard library of the C programming language, which of the following header file is designed for basic mathematical operations?

A - math.h
B - conio.h
C - dos.h
D - stdio.h

Q 11 - Choose the correct program that round off x value (a float value) to an int value to return the output value 4,

A - float x = 3.6;
     int y = (int)(x + 0.5);
     printf ("Result = %d\n", y );
B - float x = 3.6;
     int y = int(x + 0.5);
     printf ("Result = %d\n", y );
C - float x = 3.6;
     int y = (int)x + 0.5
     printf ("Result = %d\n", y );
D - float x = 3.6;
     int y = (int)((int)x + 0.5)
     printf ("Result = %d\n", y );

Q 12 - The binary equivalent of 50 is,

A - 110010
B - 1010110
C - 101
D - 101.011.00.00

Q 13 - Where to place “f” with a double constant 3.14 to specify it as afloat?

A - (float)(3.14)(f)
B - (f)(3.14)
C - 3.14f
D - f(3.14)

Q 14 - Choose the correct statement that can retrieve the remainder of division 5.5 by 1.3?

A - rem = modf(5.5 % 1.3)
B - rem = modf(5.5, 1.3)
C - rem = fmod(5.5, 1.3)
D - rem = f(5.5, 1.3)

Q 15 - In the C programming language, a function prototype is a declaration of the function that just specifies the function’s interface (function's name, argument types, and return type) and extracts the body of the function. By defining the function, we get to know what action a particular function is going to perform.

A - True
B - False

Q 16 - In C, what are the various types of real data type (floating-point data type)?

A - Float, long double
B - long double, short int
C - float, double, long double
D - short int, double, long int, float

Q 17 - Turbo C in 16 bit DOS OS, the correct range of “long double” is,

A - 3.4E-4932 to 3.4E+4932
B - 3.4E-4932 to 1.1E+4932
C - 4.1E-4932 to 5.1E+4932
D - 0.7E-4932 to 1.8E+4932

Q 18 - What is (void*)0?

A - Symbolize the NULL pointer
B - Symbolize the void pointer
C - Symbolize both, NULL & void pointer
D - Many display error

Q 19 - The C library function rewind() reposition the file pointer at the beginning of the file.

A - True
B - False

Q 20 - 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

Q 21 - For a structure, if a variable behaves like a pointer then from the given below operators which operator can be used to access data of the structure via the variable pointer?

A - .
B - %
C - ->
D - #

Q 22 - The equivalent pointer expression by using the array element a[i][j][k][2],

A - ((((a+m)+n)+o)+p)
B - *(*(*(*(a+i)+j)+k)+2)
C - *( (((a+m)+n)+o+p)
D - *( ((a+m)+n+o+p)

Q 23 - What is a pointer?

A - A keyword used to create variables
B - A variable used to store the address of an instruction
C - A variable used to store the address of other variables
D - A variable used to store the address of a structu

Q 24 - Which of the following operator can be used to access the value at address stored in a pointer variable?

A - *
B - #
C - &&
D - @

Q 25 - Which header file supports the functions - malloc() and calloc()?

A - stdlib.h
B - memory.h
C - math.h
D - stdio.h

Q 26 - What function can be used to free the memory allocated by calloc()?

A - dealloc();
B - strcat();
C - free();
D - memcpy();

Q 27 - The given below program allocates the memory, what function will you use to free the allocated memory?

#include<stdio.h>
#include<stdlib.h>

#define MAXROW 4
# define MAXCOL 5

int main ()
{
   int **p, i, j
   p = (int **) malloc(MAXROW * sizeof(int*));
   return 0;
}

A - memfree(int p);
B - free(p);
C - dealloc(p);
D - Both, free(p); & dealloc(p);

Q 28 - A bitwise operator “&” can turn-off a particular bit into a number.

A - Yes
B - &&
C - *
D - ||

Q 29 - Which header file can be used to define input/output function prototypes and macros?

A - math.h
B - memory.h
C - stdio.h
D - dos.h

Q 30 - Which library functions help users to dynamically allocate memory?

A - memalloc()and alloc() 
B - malloc() and memalloc()
C - malloc() and calloc()
D - memalloc() and calloc()

Q 31 - Which standard library function can return a pointer to the last occurrence of a character in a string?

A - stchar()
B - strrchr()
C - strchar() & stchar()
D - strrchar()

Q 32 - In the given below code, if a short int value is 5 bytes long, then how many times the while loop will get executed?

#include<stdio.h>
int main ()
{
   int j = 1;
   while(j <= 300)
   {
      printf("%c %d\n", j, j);
      j++;
   }
   return 0;
}

A - Unlimited times
B - 0 times
C - 300 times
D - 5 times

Q 33 - Similarity between a structure, union, and enumeration,

A - All are helpful in defining new variables
B - All are helpful in defining new data types
C - All are helpful in defining new pointers
D - All are helpful in defining new structures

Q 34 - In the Decimal system you can convert the binary number 1011011111000101 very easily.

A - Yes
B - Hexadecimal system
C - Octal system
D - Both, Octal & Decimal

Q 35 - Which of the following is a logical operator?

A - !
B - &&
C - ||
D - All of the above

Q 36 - Which of the following is a logical OR operator?

A - &
B - &&
C - ||
D - None of the above

Q 37 - The correct order of mathematical operators in mathematics and computer programming,

A - Addition, Subtraction, Multiplication, Division
B - Division, Multiplication, Addition, Subtraction
C - Multiplication, Addition, Division, Subtraction
D - Mathematical operators can be done in any order

Q 38 - “Stderr” is a standard error.

A - Yes
B - Standard error streams
C - Standard error types
D - Standard error function

Q 39 - Which of the following is a logical NOT operator?

A - !
B - &&
C - &
D - All of the above

Q 40 - Which library function can convert an integer/long to a string?

A - ltoa()
B - ultoa()
C - sprintf()
D - None of the above

Q 41 - Which of the following statement can be used to free the allocated memory?

A - remove(var-name);
B - free(var-name);
C - vanish(var-name);
D - erase(var-name);

Q 42 - Which of the following is a logical AND operator?

A - !
B - &&
C - ||
D - &

Q 43 - Which library function can convert an unsigned long to a string?

A - ltoa() 
B - ultoa()
C - system() 
D - unsigned long can’t be converted to a string

Q 44 - Why use flush() library function?

A - To flush all streams and specified streams
B - To flush the only specified stream
C - To flush input/output buffer
D - Invalid library function

Q 45 - In DOS, What is the purpose of the function randomize() in Turbo C?

A - Displays a random number generator with a random value based on time
B - Displays a random number
C - Displays a random number generator in the specified range.
D - Invalid function

Q 46 - How many times the given below program will print "India"?

#include<stdio.h>
int main ()
{
   int x;
   for(x=-1; x<=20; x++)int i;
   {
   if(x < 10)
      continue;
   else
      break;
   printf("India");
}

A - Unlimited times
B - 21 times
C - 0 times
D - 20 times

Q 47 - Which of the following variable cannot be used by the switch-case statement?

A - char
B - int
C - float
D - Double

Q 48 - The return keyword used to transfer control from a function back to the calling function.

A - Yes
B - Switch
C - go back
D - goto

Q 49 - How many times the given below program will print "IndiaPIN"?

#include<stdio.h>
int main ()
{
   printf("IndiaPIN");
   main();
   return 0;
}

A - Unlimited times
B - 0 times
C - 100 times
D - Till stack run over

Q 50 - What do you mean by “int (*ptr)[10]”

A - ptr is an array of pointers to 10 integers
B - ptr is a pointer to an array of 10 integers
C - ptr is an array of 10 integers
D - Invalid statement

Q 51. C Programming Language is often called as :

a) High-Level Language
b) Middle-Level Language
c) Low-Level Language
d) None of these

Q 52. Which of the following is true about C programming language?

a) C is a structural language
b) C is a procedural language.
c) C does not support function within a function.
d) All of these

Q 53. How many keywords are there in the C programming language?

a) 32
b) 28
c) 21
d) None of these

Q 54. Which is not the extended keyword in C?

a) Imaginary
b) _Complex
c) inline
d) None of these

Q 55. Process in which source code is combined with object code is termed as:

a) Linker
b) Loading
c) Linking
d) None of these

Q 56. An object of type ‘char’ is of :

a) 1 byte
b) 2 bytes
c) 4 bytes
d) 8 bytes

Q 57. For 32 bits environment, the size of the ‘int’ data type is:

a) 2 bytes
b) 4 bytes
c) 8 bytes
d) None of these

Q 58 . What is the minimal range of unsigned char data types?

a) -127 to 127
b) 0 to 255
c) -32767 to 32767
d) None of these

Q 59. In C, the names of variables, functions, labels, and various other user-defined items are

a) keywords
b) Tokens
c) Identifiers
d) None of these

Q 60. Variables that are declared inside a function are:

a) constants
b) literals
c) global
d) local

Q 61. All non-global variables are by default :

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

Q 62. You can direct the compiler to retail the values of local variables using _ modifier.

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

Q 63. main() is :

a) keyword
b) function
c) both
d) None of these

Q 64. This modifier tells the compiler that the value of the variable may change at any time – without any action being taken by the code the compiler finds nearby.

a) extern
b) public
c) void
d) volatile

Q 65. Variables with keywords are only declared not defined.

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

Q 66. Which of the following statement about ‘static variables’ is false?

a) Static variables are permanent variables within their own function or file.
b) Static local variables are not known outside the function or file.
c) Static variables maintain their values during function calls.
d) Static variables and global variables are the same.

Q 67. Which operator is used to return he length of the variables in bytes?

a) size()
b) length()
c) leng()
d) sizeof()

Q 68. The format identifier ‘%i’ is also used for :

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

Q 69. Which data type is best for storing a number 65000 in a 32- bit system?

a) int
b) long
c) signed short
d) unsigned short

Q 70. Which header file can be used to define the i/o function prototypes and macros?

a) stdio.h
b) conio.h
c) stdlib.h
d) alloc,h

Q 71. Which of the following is an invalid if-else statement?

a) if (if (a == 1)){}
b) if (func1 (a)){}
c) if (a){}
d) if ((char) a){}

Q 72. According to the ANSI specification, how to declare the main () function with command-line arguments?

a) int main(int argc, char *argv[])
b) int char main(int argc, *argv)
c) Both of the above
d) None of the above

Q 73. const int *ptr; Which statement is true?

a) You cannot change the value pointed by ptr
b) You cannot change the pointer ptr itself
c) You May or may not change the value pointed by ptr
d) You can change the pointer as well as the value pointed by it

Q 74. _ is used to break out of a program?

a) break
b) continue
c) terminate
d) exit

Q 75. Which is an indirection operator among the following?
a) &
b) $
c) *
d) .

Q 76. Which of the following does not initialize ptr to null (assume a = 0)?

a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int ptr = a – a;
d) All of the mentioned

Q 77. If : char s[10],p; p = s; then, s[i] can be written as :

a) s – i
b) p + i
c) *(s + i)
d) *(p + i)

Q 78. When a function is called by itself again and again, then it is:

a) call by value
b) call by reference
c) recursion
d) system function call

Q 79. Which can never be called by value using the call by value method?

a) structure
b) union
c) array
d) all of these

Q 80. What is the maximum number of arguments that can be passed in a single function?

a) 341
b) 263
c) 253
d) 308

Q 81. is the collection of similar-type elements?

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

Q 82. Which is true about following statement in C :
void ( * abc( int, void ( def) () ) ) ();

a) abc is a pointer variable to pointer-type function def.
b) Illegal statement
c) abc is a ptr to a function that takes 2 parameters.
d) None of the above

Q 83. What can not be declared:

a) Array of integers
b) Array of pointers
c) Array of structures
d) None of the above

Q 84. Which of the following is not an arithmetic operation:

a) n/=10
b) n=10
c) n+=10
d) n!=10

Q 85. Which datatype is not applicable for mod(%) operation?

a) int
b) float
c) char
d) None of these

Q 86. Functions with the same name and different parameters
represents :

a) function overloading
b) function overriding
c) recursion
d) None of the mentioned

Q 87. getch() is present in this header file

a) stdio.h
b) conio.h
c) stdlib.h
d) None of the mentioned

Q 88. This keyword is used for defining new data type names.

a) docstring

b) typedef

c) Both of them

d) None of them

Q 89. Which precision specifier the number of significant digits?

a) %g
b) %G
c) %f
d) Both a and b

Q 90. In order to display the address, we need :

a) %q
b) %a
c) %p
d) None of the mentioned

Q 91. is used to take user input in C.

a) input()
b) printf()
c) scanf()
d) None of the above

Q 92. ‘%[ ]’ is used for :

a) taking an array as input
b) scans for the set of characters
c) takes an integer as input
d) None of the above

Q 93. To avoid repetition of code and bulky programs, statements
are isolated inside a __
.

a) Functions
b) Modules
c) Header Files
d) None of the above

Q 94. In C, the order of passing arguments to a function is done :

a) left to right
b) right to left
c) Randomly
d) Manually

Q 95. pow() is present in which header file?

a) maths.h
b) arithmetic.h
c) process.h
d) math.h

Q 96. In pointers, the meaning of ‘*’ is :

a) pointer variable
b) value at address
c) value of an address
d) None of the mentioned

Q 97. When double is converted to float then the value is?
a) Truncated
b) Rounded
c) Depends upon the compiler
d) None of the mentioned

Q 98. Can we declare a function inside the structure of C?

a) YES
b) NO
c) Both of them
d) None of them

Q 99. Which of the following is a ternary operator in C?

a) &&
b) %%
c) !=
d) ?:

Q 100. What is the use of the ‘%%’ specifier?

a) Finding remainder
b) Finding quotient
c) Printing % sign
d) Ncone of the mentioned


Question NoAnswer
1B
2A
3B
4A
5B
6D
7B
8B
9B
10A
11A
12A
13C
14C
15A
16C
17B
18A
19A
20B
21C
22B
23C
24A
25A
26C
27B
28A
29C
30C
31B
32C
33B
34B
35D
36C
37B
38B
39A
40A
41B
42B
43B
44A
45A
46C
47C
48A
49D
50B
51B
52D
53A
54D
55C
56A
57B
58A
59C
60D
61A
62B
63B
64D
65B
66D
67D
68B
69D
70A
71A
72A
73A
74D
75C
76A
77D
78C
79C
80C
81C
82C
83D
84B
85B
86A
87B
88B
89D
90C
91C
92B
93A
94B
95D
96B
97C
98B
99D
100C

If you any have doubt,suggestion regarding this post or website then feel free to share with us.
 
If you have learned something new from this post then share this post with your family and
friends.
 
Happy Learning :)😎  



2 Comments

Previous Post Next Post