

MCQOPTIONS
Saved Bookmarks
1. |
Which of the following statements are correct about the program? #include char *fun(unsigned int num, int base); int main() { char *s; s=fun(128, 2); s=fun(128, 16); printf("%s\n",s); return 0; } char *fun(unsigned int num, int base) { static char buff[33]; char *ptr = &buff[sizeof(buff)-1]; *ptr = '\0'; do { *--ptr = "0123456789abcdef"[num %base]; num /=base; }while(num!=0); return ptr; } |
A. | It converts a number to a given base. |
B. | It converts a number to its equivalent binary. |
C. | It converts a number to its equivalent hexadecimal. |
D. | It converts a number to its equivalent octal. |
Answer» B. It converts a number to its equivalent binary. | |