Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

» Homework Problem: Here is a C \"program\", the source code for a function plus

ID: 3704735 • Letter: #

Question

» Homework Problem: Here is a C "program", the source code for a function plus3: unsigned plus3(unsigned x)( return x+3; Give it's code number in base 2 according to waht was previously described in class Hint: the code number is between 2% and 2k+1 where k is the length of the string of characters that constitutes this source code If r E A input to partial function f: A- B and no element of B is output, then we say that f(x) is undefined. In this case we also may say that f (x) diverges and denote f(x) t If E A is input to f, and a nonnegative integer value for f(x) is output, then we say f(x) . The domain of definition dom(f) of a partial function f: A B is the subset of A this by that f (x) is defined. We may also say that f (x) converges and denote this by given by Sometimes for convenience we omit parentheses and just put: dom f. The domain of defintion of pz is denoted by Wz. That is, The sets W. are called recursively enumerable (r.), or synonymously, computably enumerable (c.e.) sets » Since there is more than one way, in fact infinitely many ways, to program a partial computable function, there will be infinitely many pa in the list (4) that are the same partial computable function. In particular, there will often be partial computable functions pu and pu such that u ^ v but pu-p,.

Explanation / Answer

    #include <stdio.h>

   

    int main()

    {

        long num, decimal_num, remainder, base = 1, binary = 0, no_of_1s = 0;

  
        printf("Enter a decimal integer ");

        scanf("%ld", &num);

        decimal_num = num;

        while (num > 0)

        {

            remainder = num % 2;

            /* To count no.of 1s */

            if (remainder == 1)

            {

                no_of_1s++;

            }

            binary = binary + remainder * base;

            num = num / 2;

            base = base * 10;

        }

        printf("Input number is = %d ", decimal_num);

        printf("Its equivalent in base 2 is = %ld ", binary);
        return 0;

    }