Question

11 Write a function with the following prototype: /* Determine whether arguments can be added without overflow */ int uadd_ok

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

Solution

int uadd_ok(unsigned x, unsigned y)
{
unsigned res = x+y;

return res < x ? 0: 1;
}

Explanation

?:

ternary operator

just wrote the function prototype

if u need full program, please post question again, love to answer

all the best

Add a comment
Answer #2
int uadd_ok (unsigned x, unsigned y) {

 return (x + y) >= x;

}


source: Apphacker
answered by: CSLEARNER
Add a comment
Know the answer?
Add Answer to:
11 Write a function with the following prototype: /* Determine whether arguments can be added without overflow */ int u...
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
  • Write a statement that declares a prototype for a function divide that takes four arguments and...

    Write a statement that declares a prototype for a function divide that takes four arguments and returns no value. The first two arguments are of type int. The last two arguments arguments are pointers to int that are set by the function to the quotient and remainder of dividing the first argument by the second argument. The function does not return a value. (C Program)

  • 3. (12) Write a function named getSumSquares. You can skip writing the function prototype. This function...

    3. (12) Write a function named getSumSquares. You can skip writing the function prototype. This function has two int arguments called first and last. The function is to add up the tube of each number from first to last and return the total. (Note: the easy way to get the square of a number a is with: a * a). Square To see how the function works, here is an example. After the statement int c = getSumSquares (2, 4);...

  • Write a C function named  f such that … the prototype of function  f is … unsigned long...

    Write a C function named  f such that … the prototype of function  f is … unsigned long int f ( unsigned long int X, unsigned long int Y ) function  f returns … the nonnegative integer  Z  such that   X 2  +   Y 2  =   Z 2  if such a nonnegative integer  Z  exists zero if there is no nonnegative integer  Z  such that   X 2  +   Y 2  =   Z 2  Example 1 If   X = 3  and   Y = 4 ...

  • Write a prototype for the following function: void printNum(int number) {     cout << “The number...

    Write a prototype for the following function: void printNum(int number) {     cout << “The number is: “ << number << endl; }

  • Problem 1: Write a function add64 that adds two input unsigned 64 bit integers x and...

    Problem 1: Write a function add64 that adds two input unsigned 64 bit integers x and y and returns the unsigned 64 bit integer sum z, i.e. zx+y. In your main function, you should assume that x, y, and z will be stored in the following 6 registers as follows: x: upper 32 bits in $t1 y: upper 32 bits in St3 z: upper 32 bits in St5 lower 32 bits in $to lower 32 bits in $t2 lower 32...

  • 1. Write a statement that calls a function named showSquare, passing the value 10 as an...

    1. Write a statement that calls a function named showSquare, passing the value 10 as an argument. 2. Write the function prototype for a function called showSquare. The function should have a single parameter variable of the int data type and areturn type of void. 3. Write the function prototype for a function called showScoreswith a parameter list containing four integer variables and a return type of void. 4. Look at the following function definition: double getGrossPay(int hoursWorked, double payRate)...

  • 1. Write a function that converts a string into an int. Assume the int is between...

    1. Write a function that converts a string into an int. Assume the int is between 10 and 99. Do not use the atoi() or the stoi() function. 2. Write a function prototype for problem 1. 3. Write a function call for the function you defined in problem 1. 4. Write a function that converts an int between 10 and 99 into a string. 5. Write a function prototype for problem 4. 6. Write a function call for function you...

  • Question 14; Write a C function named isSymmetric, the prototype of which is given below, that...

    Question 14; Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters. (10 marks) Clue: Array myArray of size n is symmetric if myArray[0] is equal to myArray[n-1], myArray[1] is equal to myArray[n-2], and...

  • 5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns...

    5.43 (10 pts) What does the following program do? #include <stdio.h> 3 unsigned int mystery Cuns igned int a, unsigned int b): // function prototype 5 int main(void) printf("%s". "Enter two positive integers: unsigned int x: I/ first integer unsigned int y: // second integer scanf("Su%u". &x, &y); "); 12 13 14 15 II Parameter b must be a positive integer 16 to prevent infinite recursion 7 unsigned int mystery Cuns igned int a, unsigned int b) 18 printf("The result...

  • Write code for a function with the following prototype: // Divide by power of two. Assume...

    Write code for a function with the following prototype: // Divide by power of two. Assume 0 <= k < w-1 int divide_power2(int x, int k); The function should compute x/2 k with correct rounding (round toward 0), and it should follow the bit-level integer coding rules: • Assumptions – Integers are represented in twos-complement form. – Right shifts of signed data are performed arithmetically. – Data type int is w bits long. For some of the problems, you will...

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