Using the following description, please replace the return line in C code;  /* * sign: return 1 if positive, 0 if zero, -1 if negative * Examples: * sign(240) = 1 * sign(0) = 0 * sign(-273) = -1 * Legal ops: ! ~ & ^ | + << >> * Max ops: 10 * * */ int sign(int x) { return 2 }   You cannot: 1. Use any control constructs such as if, do, while, for, switch, etc. 2. Define or use any macros. 3. Define any additional functions in this file. 4. Call any functions. 5. Use any other operations, such as &&, ||, -, or ?:, not listed in the the "Legal ops" list for the function. 6. Use any form of casting. 7. Use any data type other than int.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question

Using the following description, please replace the return line in C code; 

/*
* sign: return 1 if positive, 0 if zero, -1 if negative
* Examples:
* sign(240) = 1
* sign(0) = 0
* sign(-273) = -1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 10
*
*
*/
int sign(int x) {
return 2
}
 
You cannot:
1. Use any control constructs such as if, do, while, for, switch, etc.
2. Define or use any macros.
3. Define any additional functions in this file.
4. Call any functions.
5. Use any other operations, such as &&, ||, -, or ?:, not listed in the
the "Legal ops" list for the function.
6. Use any form of casting.
7. Use any data type other than int.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,