Bitwise Operators

Q1:
Which of the following statements are correct about the program?
#include<stdio.h>
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.

ANS:A - It converts a number to a given base.

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.