Lecture 1: Hello World!
The Very Basics
What is a computer?
What is a computer program?
• Series of commands that the computer interprets and
• For a program to accomplish a task the commands
must be put together in a meaningful way.
What are the ingredients of a program
that does something?
• The program must be written in a programming language that the
computer can understand. There are several languages: Pascal, Fortran,
C++, Java etc.
• The program must follow the rules of the language. The programmer
must know the words and the grammar.
• The instructions must be written in the correct sequence.
• The totallity of instructions must accomplish the ...view middle of the document...
• Programming is a creative activity!
How is a C++ program written?
• It is written using the normal English alphabet and a few extra symbols
such as parenthesis ( ) and semicolons ; .
• You can write a C++ program on any text editor!
• It is, however, easier to use a program such as Microsoft Visual Studio
to help you write the code.
How do you run a C++ program?
Before you have a working program your code must
be converted to an executable file.
The computer does not understand C++ as it is written by humans. It must
be translated into machine code. The compliation process accomplishes
A source file has a name like my_program.cpp. The machine code version has name like
my_program.obj and finally the executable has a name like my_program.exe.
We do not need to understand the details of this process. We only need to know the main
idea. The end product is essentially a program of 0s and 1s that the computer understands.
I wrote my program so I am done with
the HW assignment right?
Sadly, writing a computer program itself is probably
only half the work...Three things can go wrong:
• Syntax errors, typos etc.
Run time errors
• Program crashes as it is running.
• Possible reasons: Program tried to access illegal memory location or
tried to divide by 0.
• The program is not accomplishing what it is intended.
• Possibly because the instructions are given in the wrong order or are
incorrect to accomplish the task at hand.
using namespace std;