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 4E
Program Plan Intro
- Include the necessary header files into program.
- Define the macro named “MAX3()” to find out the maximum value of three numbers.
- Define the main function
- Declare the variable “x”, “y”, and “z” in type of integer.
- Prompt and get the value of “x”, “y”, and “z” from user.
- Call the macro “MAX3()” in print function which passes “x”, “y”, and “z” as argument and print the resultant value.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
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
Write 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 AREA
Let f2(x) be the smallest number n such that x < n2. Write a program in S that computes f2. If you use any macro, you have to provide the corresponding macro expansion.
This question is related to theory of computation and I don't need any answer in C, C++ or any other programming language.
Knowledge Booster
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.arrow_forwardComputer Science Let f2(x) be the smallest number n such that x < n2. Write a program in S that computes f2. If you use any macro, you have to provide the corresponding macro expansion.arrow_forwardIntroduction to Macros in MarsRead about macros here:https://courses.missouristate.edu/kenvollmar/mars/help/MacrosHelp.htmlLab TasksIn the above tutorial on macros, a simple for loop has been implemented using macros. As you can see, it is a powerful tool to simulate code that looks like a statement in a high-level language. The for loop in the tutorial prints a range of consecutive numbers. Copy the code from the tutorial to Mars and make it execute. The macro call: for ($t0, 1, 10, body) will lead to printing numbers from 1 to 10, one each in a new line. Your task is to modify the code to pass another argument (an interval) to the macro so that the numbers are printed with the given interval in the same line where a space separates the numbers. Your program will also print a string (“Here is the output: ”) before the series of numbers using the print_str macro. For example, Macro call: for ($t0, 1, 20, 3, body) will produce the following output: Here is the output: 1 4 7 10 13 16…arrow_forward
- Follow up to previous question: Consider the definition of the printint macro:#define printint(n) printf ("%i\n", x ## n) Could the following be used to display the values of the 100 variables x1–x100: for (i = 1; i < 100; ++i) printx (i); Am I right to assume there is no way to get a loop in main() to print the given variables (ie adding x to i) using a #define macro?arrow_forwardIn Python: Build a function that takes a record from your FASTA file as an argument, and returns a count of each amino acid coded for by the codons of the sequence. Keep in mind that because these records are not necessarily in the proper reading frame, so the user should be prompted to select a reading frame (0, +1, +2). You should put some thought into the presentation of your results by your main function, making sure they are clear and readable. The fasta file contains the below: >MD10G1276500 pacid=40089867 polypeptide=MD10G1276500 locus=MD10G1276500 ID=MD10G1276500.v1.1.491…arrow_forwardWrite 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_forward
- Create a python code i. Add a function named readfile() to your program that takes a string (filename) as the parameter. You can assume that this file contains a single string. Your function must read the file and return this string. ii. Add a function named scramble() that takes a string parameter (e.g., x). You can assume that x has even length. This function must create two strings such that the first string (e.g., y) is composed of all even numbered characters in x and the second string (e.g., z) is composed of all odd numbered characters in x. For example, if x = "abcdefgh" then y is "aceg" and z is "bdfh". Your function must return these strings (e.g., y and z). iii. Add a function named writefile() to your program that takes three strings as parameter, a filename and two scrambled strings (e.g., y and z), in this order. You function must write these strings y and z on separate lines in the file. This function does not return anything. Docstrings and comments are not necessary.arrow_forward58. Write a c program to count the number of words and characters in a file. File name should be a user input. You have to use at least one macro in this code. Important: Do not copy codes from prepinsta.com.arrow_forwardcreate python algorithm for a shortest job first scheduler. the scheduler needs to be able to perform well in a varietyof metrics, such as turnaround time, response time, burst time and switching time. thescheduler needs to be able to perform well in a variety of situations, and also needs to take into account I/O Interrupts.The input is a number n, indicating the number of processes in the file, followed by n processes, each on a newline. Each process line is in the format:Process Name, Process Runtime, Process Arrival Time, IO Frequency If IO occurs for a givenprocess, then it needs to be indicated by a ! followed by the process name without a space. In this case thefequency of the IO is dependant on the “IO Frequency” parameter. It is also important to note that in this caseNO other process can be scheduled concurrently with an IO request.arrow_forward
- Write a C program as follows Firstly,your program should have a function including just a variable Suppose there is a file named first.txt. This file have just three word as math,science,letter. In your C program encryptes the each word in first.txt file by shifting the letters to a right. Then create a second file named second.txt and write these encrypted words into this file . Example: encrypted version of the word "math" must be "nbui"arrow_forward7. Write the C code which translates only the following assembly code (not a complete .c file program) and explain in words shortly what it does. Write the values of R0 and R1 after complete execution of this code. Assembly Code C Code MOV re, #0 MOV r1, #0 check loop ADD r1, r1, re ADD re, re, #1 check CMP re, #10 BLT loop B endlooparrow_forwardPlease I need a new solution ( dont give me the same solution) Write the code in data segment and code segment to simulate it. Complete code please Write an assembly MACRO that takes an integer number as parameter. Keep dividing the number by 10 until it reaches zero. Then compute the percentage of even digits in that number. ( Example if num=73458à then the percentage is = 2/5=0.4)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education