Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Along with an agile / iterative approach, it is also highly recommended that you make copies of your code along the way so you can
Along with an agileiterative approach, it is also highly recommended that you make copies of your code along the way so you can go back to a previous version if you get stuck or figure out a better way to improve your code over time this will demonstrate a form of refactoring code.
Your program will need to do the following to achieve full cred it
Start program with a command line switch that enablesdisables debugging
a If your program is in debugging mode, you will need to have various places in your code where you are doing IO that output what was either read in or the output of a function that is not going to be directly output via normal print statements.
Prompt a user for input in the form of a menu that does not exit until the user enters the selection for 'exit'. The input selection will be managed with a switch statement in Menu:
Add numbers integers
Multiply numbers floats
Read in string and reverse the string as output
Enter words
Based on the input, call a function based on the input one function per menu selection
Run the function and if needed, prompt the user for additional information to be used in
INET C Programming Language and Applications
that function for output
Read input and convert menu selections into integersfloats if needed
For the functions:
Adding numbers will require you to prompt for numbers independently, read them in convert to integers, add them together and output the result
Multinly
For the functions:
Adding numbers will require you to prompt for numbers independently, read them in convert to integers, add them together and output the result
Multiply numbers will require you to prompt for floating point numbers independently, read them in convert them to floating point variables, multiply and output with decimal points of precision
Read in a string and reverse you will prompt for a string no whitespace characters read it into a variable, reverse using a for loop that will output the string in reverse
Enter words two strings with a space between them and compare to identify if they are the same. ie "dog dog" would be the same and, "dog cat" would not be the same
For the command line switch, you will be collecting data to enabledisable debugging and using that variable in conditional testing to output debugging info or not. An example of how you will collect from the command line might look like:
$lab debug
or
$ lab nodebug
The data will be collected into a variable named 'argv
You will also need to test that the user entered an argument by checking the argument count with the variable 'argc'. If the user did not enter a command line argument you will need to output the error to the user as a "usage statement" that tells the user what they did wrong in the form of :
$ lab
Error: Usage: labdebug nodebug
And when you print this message you will need to use the "argv" variable for the program name vs hardcoding it in your program.
When your program is in debug mode, you will have various statements around your code where you are collecting input, calculating data for output, or entering exiting functions, etc. This will allow you to follow the logic as your program executes. This is an important piece of
When your program is in debug mode, you will have various statements around your code where you are collecting input, calculating data for output, or entering exiting functions, etc. This will allow you to follow the logic as your program executes. This is an important piece of learning the language as there are many low level concepts that are not fully understood by just running a program. These low level concepts will be covered in class, but a few of them are:
What a "string" really is in the programming language
How is performed and relates to variables default types, where data is stored, etc
INET C Programming Language and Applications
Ability to see logic flow throughout the program to identify defectsbugs where they started vs where they may be identified ie output
Learning objectives:
Compiling and running a C program
Input and output for standard in and standard out
Command line arguments
Looping
Conditional statements
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started