EEE-117 Computer Programming

13.10.2018

 

Hello dear students,

You may find the lab notes down below.

 

1- 

#include <iostream>
using namespace std;

int main()
{
    float firstNumber;
    float secondNumber;
    float tempNumber;
    
    // Prompt user to enter the first number.
    cout << "Enter the first number" << endl;
    cout << "Then hit enter" << endl;
    cin  >> firstNumber;
    
    // Promt user to enter the second number.
    cout << "Enter the second number" << endl;
    cout << "Then hit enter" << endl;
    cin  >> secondNumber;
    
    // Echo print the input.
    cout << endl << "You input the numbers as " << firstNumber
         << " and " << secondNumber << endl;
    
    // Now we will swap the values around *correctly*
    tempNumber = firstNumber;
    firstNumber = secondNumber;
    secondNumber = tempNumber;
       
    // Output the values.
    cout << "After swapping, the values of the two numbers are "
         << firstNumber << " and " << secondNumber << endl;
    
    return 0;    
}

2- 

#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    float number;
    int divider;
    
    divider = 2;
    
    cout << "Hi there" << endl;
    cout << "Please input a number and then hit return" << endl;
    cin  >> number;
    
    number = number / divider;
    
    cout << "Half of your number is " << number << endl;

    return 0;
}

 

SIGN UP AND STAY UPDATED!
  • Grey Google+ Icon
  • Grey LinkedIn Icon

© Digitalcastle , Keep yourself updated.

  • Google+ Social Icon
  • Twitter Social Icon
  • LinkedIn Social Icon
  • Facebook Social Icon