Top 50 C PROGRAMMING MCQ Questions and Answers Exercise (Set 2/4)

By Sahil Bansal | Views: 7585

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 structure

--------------------------------------------------------------------------------------------------------------------------------------------

Practice more questions

-------------------------------------------------------------------------------------------------------------------------------------------

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

--------------------------------------------------------------------------------------------------------------------------------------------

 QUESTION NO. ANSWERS
1.B
2.A
3.B
4.A
5.B
6.D
7.B
8.B
9.B
10.A
11.A
12.A
13.C
14.C
15.A
16.C
17.B
18.A
19.A
20.B
21.C
22.B
23.C
24.A
25.A
26.C
27.B
28.A
29.C
30.C
31.B
32.C
33.B
34.B
35.D
36.C
37.B
38.B
39.A
40.A
41.B
42.B
43.B
44.A
45.A
46.C
47.C
48.A
49.D
50.B

--------------------------------------------------------------------------------------------------------------------------------------------

ALSO READ:

Top 50 C PROGRAMMING MCQ Questions and Answers with Explanation

Top 50 C PROGRAMMING MCQ Questions and Answers Exercise (Set 1/4)

Top 50 C PROGRAMMING MCQ Questions and Answers Exercise (Set 3/4)

Top 50 C PROGRAMMING MCQ Questions and Answers Exercise (Set 4/4)

Practice our complete set of quantitative and English

-------------------------------------------------------------------------------------------------------------------------------------------

Thank you for your feedback!