Professional Documents
Culture Documents
When you press A on your keyboard, the computer displays A on the screen.
But what is actually stored inside the computer’s main memory? What is the
language of the computer? How does it store whatever you type on the keyboard?
Digital signals are more reliable carriers of information than analog signals and
can be copied from one device to another with exact precision. You might have
noticed that when you make a copy of an audio tape, the sound quality of the
copy is not as good as the original tape. On the other hand, when you copy a CD,
the copy is as good as the original. Computers use digital signal.
Because digital signals are processed inside a
computer, the language of a computer, called
machine language, is a sequence of 0s and 1s.
Possible objects:
1. Video
2. Customer
Input : number 1
number 2
Process: sum = number 1 + number 2
difference = number 1 – number 2
product = number 1* number 2
quotient = number 1 / number 2
remainder = number 1 % number 2
Output: sum
difference
product
quotient
remainder
A C++ program is a collection of one or more
subprograms, called functions. Some functions called
predefined or standard functions, are already written and are
provided as part of the system. But to accomplish most
tasks, programmers must learn to write their own
functions(user-defined functions).
Example:
/*This is a multiple-line
comment……..
*/
Note: the text after the // and between /* */ will be ignored by the
compiler.
Token – is the smallest individual unit of a program written in any
language.
3 Types:
1. Special symbols
* / % + -
. ; ? ,
<= != == >=
2. Reserved words or keywords
int char float
double string const
void return
1. lastName
2. number1
3. second_Number
4. netIncome
Examples of Invalid Identifiers:
Example:
int number1;
string firstname, lastname, middlename;
char mid_initial;
float salary, hourly_rate;
Every C++ program contains whitespaces. Whitespaces include
blanks, tabs, and newline characters.
Precedence Rules:
2. 5 – (3 + 7) / ((3 % 4) * 2) 3. 10. 5 % 3
= 5 – (3 + 7) / (3 * 2) = error
= 5 – 10 / (3 * 2)
= 5 – 10 /6
=5–1
=4
and and_eq asm auto bitand
bitor bool break case catch
char class compl const const_cast
continue default delete do double
dynamic_cast else enum explicit
export extern false float for
friend goto if include inline
int long mutable namespace new
not not_eq operator or or_eq
private protected public register
reinterpret_cast return short signed
sizeof static static_cast struct switch
template this throw true try
typedef typeid typename union unsigned
using virtual void volatile wchar_t
while xor xor_eq
used for input
Example:
Example:
double hours = 35.45;
double rate = 15.00;
Output:
hours = 35.45, rate = 15, pay = 531.75
To insert a new line
Example:
cout << “Hello!\nThis is my \nfirst program!”;
Output:
Hello!
This is my
first program!
Example:
cout << “Hello!” << endl << “This is my” << “\n”
<< “first” << ‘\n’ << “program!”;
Output:
Hello!
This is my
first
program!
String – a collection of characters
Example:
string name;
Output: