Answered step by step
Verified Expert Solution
Link Copied!

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 agile/iterative 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 enables/disables debugging
a. If your program is in debugging mode, you will need to have various places in your code where you are doing I/O 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 C. Menu:
Add 2 numbers (integers)
Multiply 2 numbers (floats)
Read in string and reverse the string as output
Enter 2 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 3101_001 C Programming Language and Applications
that function for output
Read input and convert menu selection(s) into integers/floats (if needed)
For the functions:
Adding 2 numbers - will require you to prompt for 2 numbers independently, read them in, convert to integers, add them together and output the result
2
Multinly 2
For the functions:
Adding 2 numbers - will require you to prompt for 2 numbers independently, read them in, convert to integers, add them together and output the result
Multiply 2 numbers - will require you to prompt for 2 floating point numbers independently, read them in, convert them to floating point variables, multiply and output with 3 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 2 words (two strings with a space between them) and compare to identify if they are the same. (i.e. "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 enable/disable 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:
$./lab1 debug
or
$ ./lab1 no-debug
The data will be collected into a variable named 'argv[1]'.
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 :
$ lab1
Error: Usage: lab1[debug | no-debug]
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 C 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 C programming language
How 1O is performed and relates to variables (default types, where data is stored, etc)
INET 3101_001 C Programming Language and Applications
Ability to see logic flow throughout the program to identify defects/bugs where they started vs where they may be identified (i.e. output)
Learning objectives:
Compiling and running a C program
Input and output for standard in and standard out
Command line arguments
Looping
Conditional statements
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions