C Quiz - 102

Last Updated :
Discuss
Comments

Question 1

In the context of modulo operation (i.e. remainder on division) for floating point (say 2.1 and 1.1), pick the best statement.

  • A

    For floating point, modulo operation isn't defined and that's why modulo can't be found.

  • B

    (2.1 % 1.1) is the result of modulo operation.

  • C

    fmod(2.1,1.1) is the result of module operation.

  • D

    ((int)2.1) % ((int)1.1) is the result of modulo operation.

Question 2

In the context of C data types, which of the followings is correct?
  • A
    “unsigned long long int” is a valid data type.
  • B
    “long long double” is a valid data type.
  • C
    “unsigned long double” is a valid data type.
  • D
    A), B) and C) all are valid data types.
  • E
    A), B) and C) all are invalid data types.

Question 3

Suppose a C program has floating constant 1.414, what's the best way to convert this as "float" data type?
  • A
    (float)1.414
  • B
    float(1.414)
  • C
    1.414f or 1.414F
  • D
    1.414 itself of "float" data type i.e. nothing else required.

Question 4

In the context of the following printf() in C, pick the best statement. C
i) printf("%d",8);
ii) printf("%d",090);
iii) printf("%d",00200);
iv) printf("%d",0007000);
  • A
    Only i) would compile. And it will print 8.
  • B
    Both i) and ii) would compile. i) will print 8 while ii) will print 90
  • C
    All i), ii), iii) and iv) would compile successfully and they will print 8, 90, 200 & 7000 respectively.
  • D
    Only i), iii) and iv) would compile successfully. They will print 8, 128 and 3584 respectively.

Question 5

In the context of the below program snippet, pick the best answer.

C
#include <stdio.h>
int arr[10][10][10];
int main()
{
 arr[5][5][5] = 123;
 return 0;
}

Which of the given printf statement(s) would be able to print arr[5][5][5]

C
(i) printf("%d",arr[5][5][5]);
(ii) printf("%d",*(*(*(arr+5)+5)+5));
(iii) printf("%d",(*(*(arr+5)+5))[5]);
(iv) printf("%d",*((*(arr+5))[5]+5));
  • A

    only (i) would compile and print 123.

  • B

    both (i) and (ii) would compile and both would print 123.

  • C

    only (i), (ii) and (iii) would compile but only (i) and (ii) would print 123.

  • D

    only (i), (ii) and (iii) would compile and all three would print 123.

  • E

    all (i), (ii), (iii) and (iv) would compile but only (i) and (ii) would print 123.

  • F

    all (i), (ii), (iii) and (iv) would compile and all would print 123.

Tags:

There are 5 questions to complete.

Take a part in the ongoing discussion