Array:-: An Array Is Collection of Identical Data Objects Which Are Stored in
Array:-: An Array Is Collection of Identical Data Objects Which Are Stored in
If the name of the array is X, then X[0] is the name of the element that
is in position is 0, X[1] is in position 1 and so on . In general form of ith
element is X[i - 1]. If a array has n elements, their names are X[0], X[1],
X[2]......X[n - 1].
X
X0] X[1] X[2] X[3] X[4] X[5] X[6]
multidimensional array:-
An array of array is a called a multidimensional array. It is defined
in same manner as one dimensional arrays, except that a separate pair
of square brackets Are required for each subscripts. Thus two
dimensional array will requires two pair of squares brackets and so on
The syntax is
Storage class datatype arrayname [exp 1] [exp 2]……… [exp n];
e.g. int X [4],[3];
Classes:-
A class is away to bind the data and function together in a single
unit. It is a user defined datatype which fault both the data and
function. The binding of a data and function together into a single class
type variable is called encapsulation.
Class declaration:-
The class declaration describe the type and scope of its member
class function definations describe how the class function are
implemented. The general form of class declaration is
private:-
Private member of a class can be access only from within the class
these can be used to read or write private data member the private
member cannot be access by outer class or outside the class.
Protected:-
Protected member of class can only be accessed by member
functions and friends of that class. Protected members are not
accessible to outside world i.e. out of class. Protected members are
similar to private members, the only difference is that protected
members are inheritable. Whereas private members are non-
inheritable.
Public:-
Public member can be accessed from outside class also. The public
data member can always read or write outside this class. The public
implementation operations are also called member functions or
methods or interfaces of the class. Any function can send message to
an object of this class through these interface functions
No entry private area
to private
area Data member
Member functions
Public area
Data member
Entry allowed
Member functions
to public area
Object:-
It is an entity that has state behavior and identity object are used
to model real world entities that we find everyday life. An object is an
instance of class. In general a class is a user defined data type, while an
object is an instance of class. Once a class has been declared, we can
create variables of that type by using class name.
The above program segment creates objects S1, S2, and S3 of class
student.
Control flow:-
A compound statement is a sequence of statements that is
treated as a single. A computer is a set of instructions. These
instructions are known as statements. These statements are executed
sequentially one after the other as they appear in a program. The flow
of control jumps from one part of the program to another, depending
on calculations performed in the program. Program statements that
cause such jumps are called control statements.
Condition
Statement 1
True condition
Statement 1
Statement 2
Statement 2 Statement 1
Statement 3 Statement 2
Statement 3
If statement:-
The if statement is used when conditional processing is
required. A statement or set of statement is executed when the
condition is true, otherwise these are skipped.
The syntax is
If (condition)
Statement ;
Entry
condition
True
Statments
False
Exit
The output is :
Enter the first number: 13
Enter the second number y: 10
X is greater than y
If-else statement:-
This statement works only if the condition is true. If it is not
true nothing happens, if-else statement executes one of alternatives
statements, according to the specified condition
The syntax is
If (condition)
Statement1;
else
statement2;