Introduction To Computers and C++ Programming
Introduction To Computers and C++ Programming
+1300042774
+1400593419
+1200274027
Assembly Language
Computers became more popular Machine
language programming was too slow, tedious and
error prone.
Instead of using strings of numbers directly
understandable by computers, programmers began
to use English-Like abbreviations to represent the
elementary operations of the computer These
abbreviations formed the basis of assembly
languages.
Translator programs called assemblers were
developed to convert assembly language programs
to machine language at computer speeds.
The following section of an assembly
language program also adds “overtime pay”
to “base pay” and stores the result in “gross
pay”:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
High-Level Language
Although Assembly languages are clearer to humans, they are
incomprehensible to computer until translated to machine
languages.
With the use of assembly languages, computer usage increased
rapidly: But an obvious inconvenient was highlighted:
Assembly languages required many instructions to accomplish
the simplest tasks lengthy process.
High level languages were developed to speed up the
programming process, by using single statements to accomplish
substantial tasks.
Translator programs called “Compilers” were introduced to
convert high-level language to machine languages
understandable by the machines.
High level languages allow programmers to
write instructions similar to the everyday
English language containing commonly
used mathematical notations.
The payroll example will be written like the
following in high-level languages:
Disk
Primary memory
CPU CPU takes each instruction and executes
. it, possibly storing new data values
as the program executes
Introduction to C++ programming
A simple program: printing a line of Text
int main ()
{
std::cout<<“welcome to c++!\n”; // this is a statement
Return 0; //indicates that program ended successfully
}
int main ()
{
Int integer1, integer2, sum; //declarations
std::cout<<“Enter first integer\n”; // prompt
std::cin >>integer1; // read an integer
std::cout<<“Enter second integer\n”; // prompt
std ::cin >>integer2; //read an integer
sum = integer1 + integer2; //assignment of sum
std::cout <<“Sum is “sum <<std::endl; //print sum
Return 0; //indicates that program ended successfully
}
Memory Concepts
Variable names such as integer1, integer2 and
sum actually corresponds to locations in the
computer’s memory. Every variable has a name,
a type, a size and a value.
In the addition program, when the statement :
std::cin >>integer1; is executed, the characters
typed by the user are converted to an integer
that is placed into a memory location to which
the name integer1 has been assigned by the C++
compiler.
Suppose the user enters the number 45 as the
value for integer1, the computer will place
45 into location integer1:
Example:
Memory
integer1 45
integer2 72
sum 117
Arithmetic
C++ arithmetic operators:
Multiplication * bm b*m