ENGN 38

Lab Programming Assignment #1                                                                               

 

Purpose:  To become familiar with the procedures for running a C++ program.

Instructions:
  1. Find a computer with appropriate C++ IDE software. 
  2. Type or copy and paste the program source code listed below (with your own name and student number) into the appropriate window.  
  3. Compile and run the program. Use the numbers 45 and 6 as data when prompted.
  4. Modify the program to include a beginning message “Welcome to the Arithmetic Program”. 
  5. Add code to calculate and display the product of the two numbers using the multiplication operator *.
  6. Add code to calculate and display the remainder after division using the mod operator %.
  7. Compile and run the program again. 
  8. Print out your source code and program output making sure that the formatting is up to C++ standards and professional in appearance.  If this does not fit on one page, delete enough so that it does. (Please do not make font size less than 10 points.) What to delete? What to keep? Make sure that you at least have the header as shown below (your student number, your name, the class identifier, the lab number) and the output from your program. As space permits, include any other essentials as you deem appropriate. Make sure that everything is clearly labeled and easy to read and follow. Have this one page ready to turn in by the due date.

 

Program Source Code:

//  Student Number 13
//  Kaufmyn, Wendy
//  ENGN 38
//  Lab #1

//  This program inputs two integer values from the keyboard. 
//  It then performs three arithmetic operations on the two data values.
//  Finally it outputs all the values to the screen.

#include <iostream>
using namespace std; 

int main ()
{
      int   firstNumber,
            secondNumber,
            sum,
            difference,
            quotient;    

      cout << "Enter the first number: ";
      cin  >> firstNumber;
      cout << "Enter the second number: ";
      cin  >> secondNumber;     

      sum        =  firstNumber + secondNumber;
      difference =  firstNumber - secondNumber;
      quotient   =  firstNumber / secondNumber;

      cout << "\nData values are: ";
      cout << firstNumber <<" and " <<secondNumber<<"\n\n";

      cout << "Computed values are:";
      cout << "\nSum.........." <<sum;
     
cout << "\nDifference..." <<difference;
      cout << "\nQuotient....." <<quotient; 

      cout << "\n\nEnd of Arithmetic Program\n\n"; 

      return 0;
}