Saturday, 12 October 2013

C++ course (third section 2)

C++ course (third section 2)

third section(writing your first C++ program 2)

#include <iostream>      <------ this is the header     
using namespace std;     <------ location of header files
void main( )                      <------primary function
{                                   <------marks beginning of function body
cout << “This is C++!”;    <----statement that prints a string which is: This is C++!
}                                     <----- marks end of function body


Debugging
-Error in program called bug
-Process of looking for and correcting bugs
-Three types of errors:
   –Syntax
   –Run-time
   –Logic

1)Syntax Errors
Mistakes by violating “grammar” rules 
Diagnosed by C++ compiler 
Must fix before compiler will translate code


2)Run-Time Errors
Violation of rules during execution of program 
Computer displays message during execution and execution is terminated 
Error message may help locating error

3)Logic Errors
Computer does not recognize 
Difficult to find 
Execution is complete but output is incorrect 
Programmer checks for reasonable and correct output

C++ course (third section 1)

C++ course (third section 1)

C++ course
third section(write your first C++ program 1)

First you must know some main important things about the program:

Assignment Statement
•The assignment statement takes the form:
variable=expression 
•Expression is evaluated and its value is assigned to the variable on the left side 
•In C++, = is called the assignment operator

i.e int num1,num2;
double sale;
char first;
string str;
num1=4;
num2=4*3-7;
sale=0.02;
first='A';
str="have a nice day";
OR
int num1=3;
int num2=6;
double sale=2.5;
.
.
.
.
Input (Read) Statement
•cin is used with >> to gather input
cin>>variable>>variable;
•The stream extraction operator is >> 
•For example, if miles is a double variable 
cin >> miles;
−Causes computer to get a value of type double Places it in the variable miles

•Using more than one variable in cin allows more than one value to be read at a time
•For example, if feet and inches are variables of type int, a statement such as:
cin >> feet >> inches;
−Inputs two integers from the keyboard
−Places them in variables feet and inches respectively
Increment & Decrement Operators
•Increment operator: increment variable by 1
−Pre-increment: ++variable
−Post-increment: variable++
•Decrement operator: decrement variable by 1
−Pre-decrement: --variable
−Post-decrement: variable—
•What is the difference between the following?

1)
x = 5; 
y = ++x;


2)
x = 5; 
y = x++;

The first one you increment x by 1 (which become 6) then keep it and print it if you want,

The second one you keep the value of x which is 5 and print it if you want then you increment it by one.
Output(write) statement
•The syntax of cout and << is:
cout<<expression or manipulator<<expression;
−Called an output statement 
•The stream insertion operator is << 
•Expression evaluated and its value is printed at the current cursor position on the screen

•A manipulator is used to format the output
−Example: endl causes insertion point to move to beginning of next line
i.e cout<<x<<endl;
•The new line character is '\n' 
−May appear anywhere in the string 
cout << "Hello there.";
cout << "My name is James.";
•Output: 
Hello there.My name is James.


cout << "Hello there.\n";
cout << "My name is James.";
•Output : 
Hello there.
My name is James.

C++ Course (Second Section)

C++ Course
Second section (Knowing Some Important Concepts)

The Basics of a C++ Program:

•Function: A collection of statements; when executed, accomplishes something
−May be predefined or standard
•Syntax: Rules that specify which statements (instructions) are legal.
•Programming Language: A set of rules, symbols, and special words.
•Semantic Rule: The meaning of the instruction.
•Comments:
Comments are for the reader, not the compiler.
Two types:
−Single line
// This is a C++ program. It prints the sentence:
// Welcome to C++ Programming.
−Multiple line
/*
You can include comments that can occupy several lines. 
 */
•Special symbols :
+ - * / . ; ? , <= != == >=
Reserved Words (Keywords):
Reserved words, keywords, or word symbols
−Include:
•int
•float
•double
•char
•const
•void
•return

•Identifiers:
•Consists of letters, digits, and the underscore character (_).
•Must begin with a letter or underscore.
•C++ is case sensitive.
−NUMBER is not the same as number.
•Two predefined identifiers are cout and cin.
•Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea.

Data Types:
1) Integers (int)
•Examples:
-6728
0
78
+763
 •Positive integers do not need a + sign
•No commas are used within an integer
−Commas are used for separating items in a list

2) Boolean (bool)
•bool type 
−Two Values: true and false 
−Manipulate Logical (Boolean) expressions 
•true and false are called logical values 
•bool, true, and false are reserved words 


3) Character (char)
•The smallest integral data type 
•Used for characters: letters, digits, and special symbols 
•Each character is enclosed in single quotes 
−'A', 'a', '0', '*', '+', ', '&' 
•A blank space is a character and is written ' ', with a space left between the single quotes


4) Floating-Point (float)
•C++ uses scientific notation to represent real numbers (floating-point notation)
Examples:
3.4
0.00023
-1.567
Types of float:
−Float: represents any real number 
•Range: -3.4E+38 to 3.4E+38 (four bytes) 
−Double: represents any real number 
•Range: -1.7E+308 to 1.7E+308 (eight bytes) 
−On most newer compilers, data types double and long double are same

•Maximum number of significant digits (decimal places) for float values is 6 or 7
•Maximum number of significant digits for double is 15
•Precision: maximum number of significant digits
−Float values are called single precision
−Double values are called double precision

5) String 
•Programmer-defined type supplied in ANSI/ISO Standard C++ library 
•Sequence of zero or more characters 
•Enclosed in double quotation marks 
•Null: a string with no characters 
•Each character has relative position in string 
−Position of first character is 0 
•Length of a string is number of characters in it 
−Example: length of "William Jacob" is 13

C++ Course (First Section)

C++ Course 
First Section: Introduction

Introduction to C++ Programming Language:


Welcome to my beginners guide to C++. If you are starting to program for the
first time, I hope that you find the sections I have written useful. C++ is an excellent
language to start programming in. A lot of applications that you use are probably
written in C++. Once you learn some basic concepts and other languages, like
Java or C# for example, programming will be much easier.
I have made the sections short and concise so you won’t get bored or weighed down by too much information. After each section you can rearrange the code in the examples provided or make up your own
code. Programming is very much a practical subject so you will learn a lot by messing with the code or even looking at other people’s codes.


What is a Computer Program?
A computer program is a set of instructions that a programmer writes to tell a
computer how to carry out a certain task. The instructions, however, must be in a
language that the computer understands. Computers only understand the binary language
i.e. that is composed of 1’s and 0’s. This is a low level language and very hard to
program in. So humans invented higher level languages, such as, C++ and Pascal to
make the job easier. As you will see, these languages are nearly like English, but you
don’t have the freedom to write what you like there still are rules you have to
follow.
To convert a program in C++ to a binary or executable file that the computer can
understand we use a compiler.

Monday, 23 September 2013

CCNA (fifth lecture)

Fifth Lecture 

IP addressing:
what is an ip address ?
An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication.
it consists of 4 digits separated by dot "." each digit has 8 bits , e.g: 192.168.10.1
It is classified into 5 classes:


e.g: Class A: 192.0.0.0
Class B: 192.168.0.0
Class C:192.168.10.0

Class A we can put a lot of devices and it has the largest amount among classes,
Class B contains less, and class C contains the least.

=======================================================

DNS & DHCP
DNS (Domain Name service)
An internet service that translates domain names into IP addresses and visa verse.

Ex: google IP: 173.194.41.70

DHCP(Dynamic Host Configuration Protocol)
is a network protocol used to assign IP addresses and provide configuration information to devices such as servers, desktops, or mobile devices, so they can communicate on a network using the Internet Protocol (IP).


















CCNA (fourth lecture)

Fourth Lecture

Most important protocols:


















And here are the ports number of each protocol, which means the port which packets go from:

Ethernet Cabling 
There are three ways to make your ethernet cable:
Straight-through cable
Crossover cable
Rolled cable
Later I will tell you when we use each of them
Here is the draw of the first way (Straight-through cable)

It's called straight-through because you connect both sides the same way , and the draw above shows the colors and how to connect them correctly.

second way (Cross-over)

Here we connect them in a different way and the colors above show how to.

Third way(Rolled-over)
Here we connect the first one , then the second one is connected in the opposite way .

Now, the question is: when we use the first, second, and the third way ?
Simply, here is the answer:
between these devices we use the cables as the following:

Straight-Through Cable : Host to switch or hub
                                    • Router to switch or hub

Crossover Cable: Switch to switch
                           • Hub to hub
                           • Host to host
                           • Hub to switch
                            • Router direct to host


Rolled Cable: It is typically used to connect a computer terminal to the console port of a router
(I will show you later when we use it and how)

Saturday, 21 September 2013

CCNA (third lecture)

Third Lecture
Data Encapsulation 

The OSI Reference Model 
Open Systems Interconnection
7-layer
It divides the network communication process into smaller and simpler components, thus
aiding component development, design, and troubleshooting.
It allows multiple-vendor development through standardization of network components.
It encourages industry standardization by defining what functions occur at each layer of
the model.
It allows various types of network hardware and software to communicate.
Upper Layers

Lower Layers

The OSI reference model has seven layers:
Application layer (layer 7)
Presentation layer (layer 6)
Session layer (layer 5)
Transport layer (layer 4)
Network layer (layer 3)
Data Link layer (layer 2)
Physical layer (layer 1)

Layer functions

The Application Layer
interface between the actual application program and the next layer down
file transfers and email.
The Presentation Layer
It presents data to the Application layer
Data translation and code formatting.
EBCDIC to ASCII translation services
Data compression and  decompression
Data encryption, and decryption
The Session Layer
The Session layer is responsible for setting up, managing, and then tearing down sessions between Presentation layer entities.
simplex, half duplex, and full duplex.

The Transport Layer
segments and reassembles data into a data stream.
connectionless or connection-oriented
Flow Control


The Network Layer
Route update packets
Network addresses

==============================================
MAC Addressing 
Layer 2 Address
48- Bit
Hexadecimal

 
biz.