The First Program

Simple input and output are the focus of this this tutorial. It should also serve to make you feel comfortable with the compiler in your development environment or how to use your shell.

 

Tasks

Write a single program for each of the following:

If you do not know the meaning of the red L's have a look at this link.

Issues

Always check the pre- and postcondition for each algorithm. Implement checks for errors as required.

C++ Reference Implementation

#include<iostream>
int main()
{
  double a, b;
  std::cout << "Please enter a: " ;
  std::cin >> a;
  std::cout << "Please enter b: " ;
  std::cin >> b;
  if (b !=0.0)
   std::cout << "Result of a/b: " << a / b << std::endl;
  return 0;
}