Week 2 Add two integers Solution

$30.00 $24.00

Overview 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. Program Description This program will sum two integer numbers to yield a third integer number. Once the calculations are made the results of all…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Overview

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.

Program Description

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.

Analysis

We will use sequential programming statements.

We will define 3 integer numbers: x, y, z

z will store the sum of x and y.

Test Plan

To understand this program the following input numbers could be used for testing:

x = 10

y = 20

z = x + y = 10 + 20 = 30

In table format the following results are expected:

Run #

Input x

Input y

Expected Output

1

10

20

30

2

0

0

0

3

124

356

480

4

-30

-90

-120

Design using Pseudocode

  • This program will sum two integer numbers to yield a third integer number.

  • Later, it will divide two float numbers to yield a third float number.

    • Declare variables

Declare x, y, z as Integer

  • Set values of Integers Set x=10

Set y=20

Set z= x + y

  • Print x, y, z

Print x,y,z

C Code

The following is the C Code that will compile in execute in the online compilers.

  • C code

  • This program will sum two integer numbers to yield a third integer number.

  • Developer: Faculty CMIS102

  • Date: Jan 31, XXXX

#include <stdio.h>

int main ()

{

/* variable definition: */

int x, y, z;

/* variable initialization */

x = 10;

y = 20;

z = x + y;

printf(“Integers (x,y) and sum (z) are : %d,%d,%d \n”, x,y,z); return 0;

}

Results from running the programming at repl.it:

2

Learning Exercises for you to complete

  1. Change the code to include your name, the name of this class, and the name of this project as the initial part of the output.

  1. Demonstrate you successfully followed the steps in this lab by preparing screen captures of you running the lab as specified in the Instructions above.

  1. (Tests: x*y): Prepare a new test table with at least 3 distinct test cases listing input and expected output for the product of two integers.

  1. (x*y): Change the C code to calculate the product of two integers as opposed to the sum of two integers. Then run the new code. Support your experimentation with a screen capture of the code and a screen capture of the successful execution of the new code. Include screen shots of the executions of all test table values working properly.

  1. (Tests: x/y): Prepare a new test table with at least 3 distinct test cases listing input and expected output for the quotient of two floats.

  1. (float x/y): Change the C code to calculate the quotient (i.e. x/y) 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 executions the new code.

  1. (int vs float): What happens if x, y, and z are declared as int and the operation is division?

Submission

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, 4, 5, 6 and 7.

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.

Grading guidelines

Exercise

Submission

Points

1

Modifies the code to include extended welcome information.

10

2

Demonstrates the successful execution of this Lab within an online

15

compiler. Provides supporting screen captures.

3

Provides a new test table with at least 3 distinct test cases listing

10

input and expected output for the product of two integers.

4

Modifies the code to calculate the product of two ints.

15

Support your experimentation with screen captures of executing

the new code.

5

Provides a new test table with at least 3 distinct test cases listing

10

input and expected output for the quotient of two floats.

6

Modifies the code to calculate the quotient of two floats. Describes

15

what happens if the denominator is 0.0? Support your

experimentation with screen captures of executing the new code.

7

Documents experiments with int division.

15

8

Document is well-organized, and contains minimal spelling and

10

grammatical errors.

Total

100

4

Week 2 Add two integers Solution
$30.00 $24.00