C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
10th Edition
ISBN: 9780134448848
Author: Paul Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
True or False? In a VBA macro you have the following statements:
Dim word As String
Dim x As Integer
word = "kodak"
x = 1
If Left(word,2) = Right(word,2) Then
x = x + 1
Else
x = x - 1
End If
MsgBox word & x
Suppose "kodak" is replaced by "kayak". Then this macro will display "2"
so this is my code:
# Define macros.macro print_str str li $v0, 4 la $a0, str syscall.end_macro
.macro for index, start, end, interval, body li index, startLoop: blt index, end, Exit body addi index, index, interval j LoopExit:.end_macro
# Main program.datamsg: .asciiz "Here is the output: "space: .asciiz " "newline: .asciiz "\n"
.text.globl main
main: # Print string print_str msg # Call macro with interval argument for $t0, 10, 40, 4, # Print current number li $v0, 1 move $a0, $t0 syscall # Print space if not last number blt $t0, 38, PrintSpace j ExitLoop PrintSpace: li $v0, 4 la $a0, space syscall j ExitLoop ExitLoop: # Print newline li $v0, 4 la $a0, newline syscall # Exit program li $v0, 10 syscall
pls take another look and correct my errors, thanks
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
Chapter E Solutions
C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
Knowledge Booster
Similar questions
- The _____________macro prints a message and terminates program execution if the value ofthe expression the macro evaluates is 0.arrow_forward3b) Write a macro that will convert a temperature reading in degrees Celsius to degrees Fahrenheit, using the formula: F = C x (9/5) + 32arrow_forwardDisplay the current time using a pre defined macro.arrow_forward
- 58. 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_forwardWrite a macro, mWriteStringAttr, that writes a null-terminated string to the console with a giventext color. The macro, parameters should include the string name and the color. Write a programthat tests your macro with three different strings in three different colors. Here's a sample call: .datamyString BYTE "Here is my string",0•codemWriteStringAttr myString, whitearrow_forwardUsing NASM on a linux machine, how can I program to calculate the average of three given numbers stored in memory. Printing them using the C language print function. Put the exit syscall in a macro called EXITPGM. If the Float-sized variable should be initialized to zero and assigned values in move immediate statements.?arrow_forward
- Introduction to Macros in MarsRead about macros here:https://courses.missouristate.edu/kenvollmar/mars/help/MacrosHelp.htmlLab TasksIn Lab 6, you modified the for-loop macro presented in the above tutorial to include an interval. If you missed lab 6 or forgot about that, here is what you needed to do there: Lab 6 starts here:The for loop in the above 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…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_forwardCOIS 2300HWinter 2023Lab 6 Introduction 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…arrow_forward
- Dont use macro Show complete code to simulatearrow_forwardNow, in this lab (Lab 7), you will make further modification to the same macro to make the for-loop more versatile. In addition to passing an interval, your macro call will be able to pass a character (‘i’ or ‘d’) indicating if you want to increment or decrement the value of the iterator. In the case of increment, the value of the to argument will be greater than the value of the from argument. Conversely, in the case of decrement, the value for the to argument will be less than the value of the from argument. Examples of macro calls and the output: Call: for ($t0, 1, 20, 'i', 3, body)Output: 1 4 7 10 13 16 19 Call: for ($t0, 20, 1, 'd', 3, body)Output: 20 17 14 11 8 5 2 Hints: In the macro, you may need to load 'i' and 'd' to two registers before comparing it to the increment/decrement type argument-register. You can use li instruction for this purpose. Based on the comparison results, your code will branch to two different labels where the iterator register will either be incremented…arrow_forwardI bolded the parts that I need a code for. I just need a code that turns lower case to upper case letters, tallys up the number of times a letter has been used and then prints it out. Extra credit is having a histogram. INCLUDE Irvine32.incINCLUDE macros.inc MAX=26 ; 26 letters A-ZBUFFER_SIZE = 8192 ; Will not be able to read file greater.data buffer BYTE BUFFER_SIZE DUP(?),0 ; buffer for file contentsfilename BYTE 80 DUP(0) ; buffer for filenamefileHandle HANDLE ? ; access to file (set in open_file proc)bufSize DWORD BUFFER_SIZE ; size buffer/#char read-set ReadTheFilefreqs DWORD MAX DUP(0) ; buffer holds count frequencies of 'A'-'Z' .codemain PROC ; get filenamemov edx,OFFSET filenamemov ecx,SIZEOF filenamecall GetFileName ; askes and fills in filename buffer ; open the filecall OpenTheFile ; uses filename sets fileHandle ; read the file text into buffermov edx,OFFSET buffermov ecx,BUFFER_SIZEcall ReadTheFile ; uses fileHandle; fill buffermov bufSize, eax ; save number of chars in…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