Skip to main content
Engineering LibreTexts

16.5: Exercises

  • Page ID
    19964
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Below are some quiz questions and suggested projects based on this chapter.

    Questions

    Below are some quiz questions based on this chapter.

    1) What software entity is responsible for parsing or reading the command line arguments?

    2) What software entity is responsible for verifying or checking the command line arguments?

    3) What is the first command line argument?

    4) Explain what argc and argv refer to.

    5) In an assembly language program, where is argc passed to the program?

    6) In an assembly language program, where is argv passed to the program?

    7) If seven spaces are entered between each of the command line arguments, how are the spaces removed when the command line arguments are checked?

    8) If a number is expected as a command line argument, and the user enters “12x3” (an invalid value), is an error generated by the operating system (i.e., the loader)?

    Suggested Projects

    Below are some suggested projects based on this chapter.

    1) Implement the example program to read and display the command line arguments. Use the debugger to execute the program and display the final results. Execute the program without the debugger and verify the appropriate output is displayed to the console.

    2) Convert the command line example into a function that will display each of the command line arguments to the console. Use the debugger as necessary to debug the program. Execute the program without the debugger and verify the appropriate output is displayed to the console.

    3) Create an assembly language program to accept a file name on the command line and open the file and display the one line message contained in the file. A series of small text file should be created each containing one of the very important messages at the start of each chapter of this text. The program should perform error checking on the file name, and if valid, open the file. If the file opens successfully, the message should be read from the file displayed to the console. Appropriate error messages should be displayed if the file cannot be opened or read. The program may assume that each message will be < 256 characters. Use the debugger as necessary to debug the program. Execute the program without the debugger and verify the appropriate output is displayed to the console.

    4) Create an assembly language program that will accept three unsigned integer numbers from the command line, add the three numbers, and display each of the three original numbers and the sum. If too many or too few command line arguments are provided, an error message should be displayed. This program will require that each of the ASCII strings be converted into integer. Appropriate error checking should be included. For example, “123” is correct while “12a3” is incorrect. The main program should call functions as necessary for the ASCII to integer conversion and the output. Use the debugger as necessary to debug the program. Execute the program without the debugger and verify the appropriate output is displayed to the console.


    This page titled 16.5: Exercises is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Ed Jorgensen.

    • Was this article helpful?