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.

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

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

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

  • ((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?
  • “unsigned long long int” is a valid data type.
  • “long long double” is a valid data type.
  • “unsigned long double” is a valid data type.
  • A), B) and C) all are valid data types.
  • 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?
  • (float)1.414
  • float(1.414)
  • 1.414f or 1.414F
  • 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);
  • Only i) would compile. And it will print 8.
  • Both i) and ii) would compile. i) will print 8 while ii) will print 90
  • All i), ii), iii) and iv) would compile successfully and they will print 8, 90, 200 & 7000 respectively.
  • 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));
  • only (i) would compile and print 123.

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

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

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

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

  • 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