Question: 4. Consider the following C function or Java method (except for final print statement the code is the same): void fun (int x) {
4. Consider the following C function or Java method (except for final print statement the code is the same): void fun (int x) { int a, b, c, d; d = 1; for (a 1; a 0) { c &= b % 2; b /= 2; } d += c; } printf ("%d ", d); } void fun (int x) { int a, b, c, d; d = 1; for (a = 1; a 0) { c &= b % 2; b /= 2; } d += c; } System.out.println (d); } (a) What output will be printed for input value r = 8? (b) How many different input values r cause the function to print the result 8 ? (c) Write a function with the same behavior but only one loop (of any type) and no library call except for the print statement.
Step by Step Solution
3.42 Rating (152 Votes )
There are 3 Steps involved in it
In C programming a function is a selfcontained block of code that performs a specific task or a set ... View full answer
Get step-by-step solutions from verified subject matter experts
