Question

» Homework Problem: Here is a C program, the source code for a function plus3: unsigned plus3(unsigned x)( return x+3; Give its 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,.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

    #include <stdio.h>

   

    int main()

    {

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

  
        printf("Enter a decimal integer \n");

        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\n", decimal_num);

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

    }

Add a comment
Know the answer?
Add Answer to:
» Homework Problem: Here is a C "program", the source code for a function plus3: unsigned...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C PROGRAM When you print out the old and new bitsets, which are of type unsigned...

    C PROGRAM When you print out the old and new bitsets, which are of type unsigned char, please use the %p control character in the printff statement rather than %x or %d or %c. The compiler will complain, but we don't always listen to them anyway. The difference is it will print the bitset out in hex with a preceeding %0x. unsigned char bitset = 0x14 ; printf("Bitsrt is %p\n", bitset) ; results in Bitset is 0x14, which is what...

  • C program help 4. Write a function called scan_hex. Here is its prototype: void scan_hex(int *xptr);...

    C program help 4. Write a function called scan_hex. Here is its prototype: void scan_hex(int *xptr); Here is an example of its use, in conjunction with print_decimal. Assume that the user will type a non-negative hex number as input. Also, assume that the “digits” a-f are in lower case. Let’s say the user types 1b int x; scan_hex(&x); print_decimal(x); MODIFY THIS CODE // function inputs a non-negative integer and stores it into *xptr. // The format of the input is...

  • CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic...

    CODE MUST BE IN C++ Objective Create a program that provides the solution to a quadratic equation. Background: A quadratic equation can be generalized by equation below: f ( x )=ax2+ bx +c Closed form solutions can be found for the zeros of a quadratic function conveniently. That is the locations where the function is equal to zero can be found by the following equation: x=− b± √ b −4ac 2a Note that depending on the sign of the expression...

  • please write a C++ code Problem A: Word Shadow Source file: shadow.cpp f or java, or.cj...

    please write a C++ code Problem A: Word Shadow Source file: shadow.cpp f or java, or.cj Input file: shadow.in in reality, when we read an English word we normally do not read every single letter of that word but rather the word's "shadow" recalls its pronunciation and meaning from our brain. The word's shadow consists of the same number of letters that compose the actual word with first and last letters (of the word) in their original positions while the...

  • CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...

    CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...

  • Need this in C Code is given below e Dots l lah dit Problem 1. (30...

    Need this in C Code is given below e Dots l lah dit Problem 1. (30 points) Fre bendord.cto obtain the free in decimal representation For ATY. this problem we complete the code in i tive long inte ens (W written the following positive long term 123, 40, 56, 7, 8, 9, 90, 900 the frequencies of all the digits are: 0:4, 1:1, 2:1, 3:1, 4:1, 5:1, 6:1, 7: 1. 8: 1.9: 3 In this example, the free ency of...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

  • C-Programming please. The task is to create second-degree polynomial calculator for the function, its integral and...

    C-Programming please. The task is to create second-degree polynomial calculator for the function, its integral and its derivative. A second-degree polynomial is described by the equation f(x) = ax +bx+c. Evaluation of the derivative gives the instantaneous slope or rate of change as (where f'(x) is the derivative of f(x)): f"(x)=2x+b The integral of the function f(x) (let us call it F(x)) indicates the area underneath the curve. Between points x; and the area A is A = F(x)-F(x), where,...

  • okay so here is my c++ code and the errors im really stuck on fixing what...

    okay so here is my c++ code and the errors im really stuck on fixing what i did wrong it seems to be the same repeated error our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...

  • The goal is to create a code for implementing a Columns game using pygame Your program...

    The goal is to create a code for implementing a Columns game using pygame Your program will read its input via the Python shell (i.e., using the built-in input() function), printing no prompts to a user with no extraneous output other than precisely what is specified below. The intent here is not to write a user-friendly user interface; what you're actually doing is building a tool for testing your game mechanics, which we'll then be using to automatically test them....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT