Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 5E
Program Plan Intro
- Include the necessary header files into program.
- Define the macro named “SHIFT()” to find out the shifting operations.
- Define the main function
- Declare and initialize the variables “w1” and “w2” in type of unsigned integer.
- Call the macro “SHIFT ()” which pass the arguments with left and right shift values and print the resultant values on screen.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program in S that computes the function f1(x) = 3x – 3. If you need any macros, please define the
macro expansions. Note that f1(x) is not defined if x = 0.
Give an example for this macros to explain its work:
The Code is C
Write a C Program that defines and uses a macro that calculates the minimum of 2 integers. Then, extend this program with another macro to calculate the minimum of 4 integers. This extended program must use the macro, which calculates the minimum of 2 integers. The program should get the input of 4 integers and print the minimum value as the result.
The approach must use macros.
For example:
Input
Result
100
200
300
400
100
Knowledge Booster
Similar questions
- Write a program that defines and uses a macro to square a random number. Try one of the new random calls in your code. Using C or C++arrow_forwardWrite a c++ program to print the area of a square (Area = s2, where a is the length of s side which will be given during the run-time) A. Use a parameterized macro for finding the square of a number with symbol SQR B. Use a parameterized/nested macro for finding the area of the square with symbol AREAarrow_forwardWrite a macro in VBA to approximate the value of the function f(x) = tan (x) at some nonzero point x in radians, using a Maclaurin series through the second derivative term (MLO 3.3). Allow the point x to be input using the InputBox() command. Calculate (a) an upper bound for the remainder term Rn , (b) the exact value of the function at x , (c) the true error Et and the true relative error (MLO 3.2) Output all these values to a blank Excel sheet, and include proper labels! Neatness counts!arrow_forward
- Use programming language C: Write four macros to re-implement the given four functions (1st attachment). Name them: subm, cubem, minm, and oddm, respectively. Then, write a main() function to test these functions and macros. Use the following test cases in the main() to call your functions and macros in this order and observe the results. (2nd attachment) *The function-macro pair should give different results, like oddf(a++) and oddm(a++).*arrow_forwardWrite a c++ program to read any 3 integers from the user and display the sum of the input values. Use parameterized/nested macro with symbols A, B, C for inputs and ANS for output.. Multi Line Text.arrow_forwardQuestion on Preprocessor (Programming in C, by Kochan) Consider the definition of the printint macro:#define printint(n) printf ("%i\n", x ## n) Could this macro be used to display the values of the 100 variables x1–x100: for (i = 1; i < 100; ++i) printint (i); I've tried various definitions for the macro and none of them work. Am I right to assume there is no way to get the following loop in main() to print x1–x100 variables (ie adding x to i) using such (or any other) #define macro?arrow_forward
- Consider the code below: void f(int a, int b) { b=5; b=a; } int g() { int i = 3; f(i+1,i); return i; } Explain what function g()returns assuming that macro expansion (textual substitution) is used as a mechanism for passing parameters. Do the same exercise for call-by-value-result.arrow_forwardIn the study of assemblers what is a macro command? What is an example of macro command? When we should program a function, and when we should program a macro command?arrow_forwardWrite an assembly program that has a macro maximum that finds the larger of two numbers inputted by the user. please show screenshot of output tooarrow_forward
- The Problem: Parameterized macros can cause unexpected things to happen. Consider the following case:#define SQUARE(x) ((x) * (x))int i = 5;int j = SQUARE(i++);What's the value of j? The answer is that it's compiler dependent. And the value of i is definitely not 6. Why? Just look at the code after the macro is expanded:int j = ((i++) * (i++));From this we can see that i is increment twice. Also since the order of the operations is not specified by the C++ standard, the actual value of j is compiler dependent.arrow_forwardpython Q4: Scheme def Implement def, which simulates a python def statement, allowing you to write code like (def f(x y) (+ x y)). The above expression should create a function with parameters x and y, and body (+ x y), then bind it to the name f in the current frame. Note: the previous is equivalent to (def f (x y) (+ x y)). Hint: I strongly suggest doing the WWPD questions on macros first as understanding the rules of macro evaluation is key in writing macros. (define-macro (def func bindings body) 'YOUR-CODE-HERE)arrow_forwardSet a macro with symbol ABOUTME with your Student ID and Full Name in the replacement string.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage