**DOWNLOAD FREE PDF** **<<CLICK HERE>>**

## Data Structure Questions and Answers-Decimal to Binary Conversion using Recursion

Congratulations - you have completed *Data Structure Questions and Answers-Decimal to Binary Conversion using Recursion*.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%

Your answers are highlighted below.

Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Which of the following is the binary representation of 100?

1010010 | |

1110000 | |

1100100 | |

1010101 |

Question 1 Explanation:

100 = 64 + 32 + 4 = 2

^{6}+ 2^{5}+ 2^{2}= 1100100.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Consider the following iterative code used to convert a decimal number to its equivalent binary:

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; .....; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 10; dec....to....bin(n); return 0; }

Which of the following lines should be inserted to complete the above code?

n- | |

n /= 2 | |

n /= 10 | |

n++ |

Question 2 Explanation:

The line "n /= 2" should be inserted to complete the above code.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the output of the following code?

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; n /= 2; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 63; dec....to....bin(n); return 0; }

111111 | |

111011 | |

101101 | |

101010 |

Question 3 Explanation:

The program prints the binary equivalent of 63, which is 111111.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the output of the following code?

#include<stdio.h> void dec....to....bin(int n) { int arr[31], len = 0, i; if(n == 0) { arr[0] = 0; len = 1; } while(n != 0) { arr[len++] = n % 2; n /= 2; } for(i=len-1; i>=0; i--) printf("%d", arr[i]); } int main() { int n = 0; dec....to....bin(n); return 0; }

0 | |

1 | |

Runtime error | |

Garbage value |

Question 4 Explanation:

The program prints the binary equivalent of 0, which is 0.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the time complexity of the above code used to convert a decimal number to its binary equivalent?

O(1) | |

O(n) | |

O(n ^{2}) | |

O(logn) |

Question 5 Explanation:

The time complexity of the above code used to convert a decimal number to its binary equivalent is O(logn).

Once you are finished, click the button below. Any items you have not completed will be marked incorrect.

There are 5 questions to complete.