This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design, and implementation with C code.
This program will sum two integer numbers to yield a third integer number. Once the calculations are made the results of all the numbers will be printed to the output screen.
We will use sequential programming statements.
We will define 3 integer numbers: a, b, c.
c will store the sum of a and b.
To understand this program the following input numbers could be used for testing:
a = 10
b = 20
c = a + b = 10 + 20 = 30
In table format the following results are expected:
|Run #||Input a||Input b||Expected Output|
Design using Pseudocode
// This program will sum two integer numbers to yield a third integer number.
// It will also divide two float numbers to yield a third float number.
// Declare variables
Declare a,b,c as Integer
// Set values of Integers
Set c= a + b
// Print a, b, c
The following is the C Code that will compile in execute in the online compilers.
Results from running the programming at ideone.com:
Learning Exercises for you to complete
- Change the C code to calculate the product of two integers as opposed to the sum of two integers. Support your experimentation with a screen capture of executing the new code.
- Prepare a new test table with at least 3 distinct test cases listing input and expected output for the product of two integers.
- Change the C code to calculate the quotient (e.g. a/b) of two floats (e.g. 2.3/1.5).Hint: Use float variable types as opposed to integers. What happens if the denominator is 0.0? Support your experimentation with screen captures of executing the new code
- Prepare a new test table with at least 3 distinct test cases listing input and expected output for
the quotient of two floats.
- Submit a neatly organized word (or PDF) document that demonstrates you successfully executed this lab on your machine using an online compiler. You should provide a screen capture of the resulting output.
- Also, provide the answers, associated screen captures, C Code and descriptions of your successful completion of learning exercises 1, 2, 3 and 4.
- The answers to the learning exercises, screen captures, C code and descriptions can be included in the
same neatly organized document you prepared as you ran this lab. Note the code can be embedded in the word document. However; be sure all code compiles and runs perfectly before submitting the document.
- Submit your document no later than the due date listed in the syllabus or calendar.