File Processing – More Recent History
DATA TYPE
4. Backslash Character Constants in C:
o There are some characters which have special meaning in C language.
o They should be preceded by backslash symbol to make use of special function of them. o Given below is the list of special characters and their purpose.
C++
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
Overview
C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form programming language that supports procedural, object-oriented, and generic programming.
C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features.
C++ was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New Jersey, as an enhancement to the C language and originally named C with Classes but later it was renamed C++ in 1983.
C++ is a superset of C, and that virtually any legal C program is a legal C++ program.
Note: A programming language is said to use static typing when type checking is performed during compile-time as opposed
to run-time.
Object-Oriented Programming
C++ fully supports object-oriented programming, including the four pillars of object-oriented development:
Standard Libraries
Standard C++ consists of three important parts:
brary giving a rich set of functions manipulating files, strings, etc.
Use of C++
C++ is used by hundreds of thousands of programmers in essentially every application domain.
C++ is being highly used to write device drivers and other softwares that rely on direct manipulation of hardware under realtime constraints.
C++ is widely used for teaching and research because it is clean enough for successful teaching of basic concepts.
Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++
C++ Basic Syntax
When we consider a C++ program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instant variables mean.
Object - Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors -
wagging, barking, eating. An object is an instance of a class.
Class - A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. Methods - A method is basically a behavior. A class can contain many methods. It is in methods where the logics are
written, data is manipulated and all the actions are executed.
Instant Variables - Each object has its unique set of instant variables. An object's state is created by the values assigned
to these instant variables.
C++ Program Structure:
Let us look at a simple code that would print the words Hello World. #include<iostream>
// main() is where program execution begins. int main()
{
cout <<"Hello World";// prints Hello World return0;
}
Let us look various parts of the above program: For this program, the header <iostream> is needed.
using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent addition to
C++.
// main() is where program execution begins. is a single-line comment available in C++. Single-line
comments begin with // and stop at the end of the line.
int main() is the main function where program execution begins.
cout << "This is my first C++ program."; causes the message "This is my first C++ program" to be
displayed on the screen.
return 0; terminates main( )function and causes it to return the value 0 to the calling process. C++ Identifiers:
A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9). C++ does not allow punctuation characters such as @, $, and % within identifiers. C++ is a case-sensitive programming language. Thus, Manpower and manpower are two different identifiers in C++.
Here are some examples of acceptable identifiers: Mohd zara abc move_ name a_123
myname50 _temp j a23b9 retVal
C++ Keywords:
The following list shows the reserved words in C++. These reserved words may not be used as constant or variable or any other identifier names
Asm else new this
Auto enum operator throw
Bool explicit private true
Break export protected try
Case extern public typedef
Catch false register typeid
Char float reinterpret_cast typename
Class for return union
Const friend short unsigned
const_cast goto signed using
continue If sizeof virtual
Default inline Static void
Delete int static_cast volatile
Do long Struct wchar_t
Double mutable Switch while
A digital system can understand positional number system only where there are only a few symbols called dig its and these symbols represent different values depending on the position they occupy in the number.
A value of each dig it in a number can be determined using The digit
The position of the dig it in the number
The base of the number system (where base is defined as the total number of dig its available in the number system).
Decimal Number System
The number system that we use in our day-to-day life is the decimal number system. Decimal number system has base 10 as it uses 10 dig its from 0 to 9. In decimal number system, the successive positions to the left of the decimal point represent units, tens, hundreds, thousands and so on.
Each position represents a specific power of the base (10). For example, the decimal number 1234 consists of the dig it 4 in the units position, 3 in the tens position, 2 in the hundreds position, and 1 in the thousands position, and its value can be written as
(1x1000)+ (2x100)+ (3x10)+ (4xl) 1000 + 200 + 30 + 1
1234
As a computer programmer or an IT professional, you should understand the following number systems which are frequently used in computers.
Binary Number System
Characteristics
Uses two dig its, 0 and 1.
Also called base 2 number system
Each position in a binary number represents a 0 power of the base (2). Example 20
Last position in a binary number represents a x power of the base (2). Example 2x where x represents the last position - 1.
Example
Binary Number: 101012
Octal Number System
Characteristics
Uses eig ht dig its, 0,1,2,3,4,5,6,7. Also called base 8 number system
Each position in a octal number represents a 0 power of the base (8). Example 80
Last position in a octal number represents a x power of the base (8). Example 8x where x represents the last position - 1.
Example
Octal Number: 125708
Calculating Decimal Equivalent
Hexadecimal Number System
Characteristics
Uses 10 dig its and 6 letters, 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
Letters represents numbers starting from 10. A = 10. B = 11, C = 12, D = 13, E = 14, F = 15. Also called base 16 number system
Each position in a hexadecimal number represents a 0 power of the base (16). Example 160
Last position in a hexadecimal number represents a x power of the base (16). Example 16x where x represents the last position - 1.
Example
Hexadecimal Number: 19FDE16 Calculating Decimal Equivalent: