Top

Discussion

What will be the output of the following C code?

void main() 
{ 
   div_t  res;  
   res = div(34, 4); 
   printf("quotient part = %d\n", res.quot); 
   printf("remainder part = %d\n", res.rem); 
}

 

  • A.
    quotient part=0
    remainder part=4
  • B.
    quotient part=8
    remainder part=2
  • C.
    quotient part=4
    remainder part=0
  • D.
    quotient part=2
    remainder part=8

Answer: B

div_t div(int n, int d) used to divide n (numerator) by d (denominator). div_t is a structure defined in ,which has two members
int quot;
in rem;

No comment is present. Be the first to comment.
Loading…

Post your comment