A conclusion on about how to write maths on a computer
Answers
computer to perform some task, which could be anything from summing the numbers from 1 to 10 to modelling the climate. When the computer follows the instructions given in the program, we say that the computer is running the program. There are many different ways of writing these instructions for the computer (we speak of programming in different languages) - in this article, we will use a language called C++. By the end of it you will be able to write your own programs to perform basic mathematical and scientific tasks.
Our first C++ program
Our first C++ program will tell the computer to print out the text "Hello world!". Here it is (don't worry - it will be explained line by line).
#include
using namespace std;
int main()
{
//
{
n = n/2;
}
else
{
n = 3*n + 1;
}
}
}
Exercise: Write a C++ program that implements Euclid's algorithm.