Pages

January 31, 2013

I/O File Handling in C++ (OOPs)


Input output file handling in C++ (OOPs) banner

A File is a bunch of bytes stored on some storage device like magnetic disk or tape etc. Most of the application programs process large volume of data which is permanently stored in files. We can write programs that can read data from file(s) and write data to file(s). 

Polymorphism in C++ (OOPs)


polymorphism sequence and types with description in C++ (OOPs)

Polymorphism is made from two words POLY+MORPHISM which means more the one form. In C++ polymorphism is implemented by overloading a function or an operator. In Function Overloading a single function name is used to perform different tasks. 

January 30, 2013

Inheritance in C++ (OOPs)


Inheritance (reusability) of codes in C++ (OOPs) programming language

It is the process by which objects of one class acquire the properties of objects of another class. The old class is referred as Base CLASS and the class that inherits the Base Class if Derived CLASS

Constructors & Destructors in C++ (OOPs)


constructors and destructors in C++ (OOPs) programming language

In C++, a class only creates a data type and the objects of a class are created and initialized as separate. A constructor (having the same name as that of a CLASS) is a member function which is automatically used to initialize the objects of the CLASS type with legal initial values.

Friend Function in C++ (OOPs)


friend function and class in C++ (OOPs) programming language


A Friend Function is a non-member function that can access private data’s. A friend CLASS is a class whose member functions can access another class i.e. private and protected classes. 

Classes & Objects in C++ (OOPs)


practical use of classes and objects in C++ (OOPs) programming language

“C with classes” was the original name given by the originator Stroustrup initially, which now days is popular known form as C++ or OOPs (Object Oriented Programming). Classes and objects are the most important feature of C++. The Class implements OOPs features and ties then together. We have already seen that a structure groups different types of elements and a function organizes the program actions to perform the desired task.

Manipulators in C++ (OOPs)

manipulators in C++ (OOPs)


Some standard manipulators are used in C++ (OOPs) which are stored under header file iomanip.h. Under this it has capabilities to show inter-conversions like binary, decimal, hex-decimal, set the precision for more accurate answer and various other functions like you can see in the programs.

Structures in C++ (OOPs)


implementation of structures in programming from day to day life in C++ (OOPs)

Structure is the user defined data type which can store heterogeneous data i.e. data of different types. It means in structure member with all possible data type can be used and there is no restriction that elements of the structure are stored at adjacent memory locations. Structure is declared with key word struct followed by its name and then by block. 

Pointers in C++ (OOPs)


syntax and working of showing how pointers points to its particular value in C++ (OOPs)

Pointer is that variable which stores the memory address of another variable. It means pointer is itself a variable which stores hex-decimal address of the location.

January 29, 2013

Arrays in C++ (OOPs)


chess array banner with king and queen in C++ (OOPs)

Array is an arrangement of same type of data at adjacent memory locations. Array is useful whenever large volume of data is to be processed and stored in the memory.

Suppose an average marks are to be calculated from all the students in the school. This is difficult to find the sum of marks of all students. In this situation an array is the best alternative. Its divided in two categories:

1. Single / 1-D Array
2. Multi-dimension Array

Loop Control- Nested for in C++ (OOPs)

/* Program to enter order of the matrix and print stars*/


#include<iostream.h>
#include<conio.h>
main()
{
       int m,n,i,j;
       cout<<"\n Enter order of Matrix m*n";
       cin>>m>>n;
       cout<<"\n";
       for(i=0;i<m;i++)
       {
                       for(j=0;j<n;j++)
                       {
                                       cout<<" *";
                                       }
                       cout<<"\n";
                                       }
       getch();
       }
output of program to display star matrix of any order using nested for loop in C++ (OOPs)

Loop Control- for loop in C++ (OOPs)



loop control statement banner of for loop in C++ (OOPs)

“for” loop is also structure control loop as program will run or execute if the initial condition is true otherwise it will terminate and program will run until some condition is fulfilled.

FORMAT:
for(expression1;expression2;expression3)
{
Statement1;
Statement2;
}

Switch Statement in C++ (OOPs)



switch statement banner ON OFF in C++ (OOPs)


This statement is also used for decision making. Here key word is switch followed by control variable and followed by it’s block.
In the block of switch statement multiple cases are used and each ends with break statement this is also called as early exit loop.
Out of all the cases only that case will run whose value matches with the control variable.

Loop Control- While & Do-while in C++ (OOPs)


loop control statements banner of while and do while loop in C++ (OOPs)

These are used for repeating some portion of the program either by specified number of times or until a particular condition is true.
1. while statement
2. do while statement
3. for loop

Decision Making- Nested If else in C++ (OOPs)

if else ladder (Nested if else) statements in C++ (OOPs) programming language banner


This statement can be used to select any one statement or a block which contains a set of instructions. Only that statement will execute which is true according to the data entered and rest other conditions will not executed.

Decision Making- If else statement in C++ (OOPs)

decision making-if else statement in C++ (OOPs) banner

This statement is also a conditional statement. It starts with keyword ‘if’ followed by an expression followed by “ first statement”  and “ second statement” is given after ‘else’ clause.

Format:
if(expression)
statement1;
else
statement2;

Decision Making- If statement in C++ (OOPs)

decision making if statement in C++ (OOPs) programming language banner

It is used whenever any condition is to be implemented by the user it means some conditions like:
1. If the price of the item is more than 5000 then discount is 10%.
2. If the students marks are greater than 60% then he should be in 1st division.

Simple C++ (OOPs) Programs

/* Program to enter two values and perform addition and multiplication operation*/


#include<iostream.h>
#include<conio.h>
main()
{
      int n1,n2,sum,mul;
      cout<<"\n Enter any two numbers";
      cin>>n1>>n2;
      sum=n1+n2;
      mul=n1*n2;
      cout<<"\n Sum of two numbers is "<<sum;
      cout<<"\n Multiplication of two numbers is "<<mul;
      getch();
}
output of program to enter values and perform addition and multiplication operation in C++ (OOPs)

January 23, 2013

Files Input/Output in C-language


practical significance of files input and output in C programming language

A file is a place on the disk where the group of related data are stored. The first function is to be performed when we are accessing the files is to open a file. Opening a file establishes a link between the program and the operating system about which file we want to access for what purpose. We provide the operating system to which file we want to access and for what purpose. For accessing a file we just have to name the file and plan whether we want o read data from the file or write data onto the file. The syntax for opening is:

FILE *fp;
inbuilt structure
fp= fopen( “file name”, “mode”);

Union in C-language


practical example of union in day to day life in programming

Union is that data structure which is also user defined data type but to define a union keyword union  is used instead of struct.

Structure in C-language


implementation of structures in programming from day to day life

Structure is the user defined data type which can store heterogeneous data i.e. data of different types. It means in structure member with all possible data type can be used and there is no restriction that elements of the structure are stored at adjacent memory locations. Structure is declared with key word struct followed by its name and then by block. 

Pointers in C-language


syntax and working of showing how pointers points to its particular value

Pointer is that variable which stores the memory address of another variable. It means pointer is itself a variable which stores hex-decimal address of the location.

Recursive Function


recursion abstract of desktop

This function is that function which calls itself again and again until some base criteria is fulfilled. It means it is that prototype function in which its name appears as a statement at least once. 

Prototype Function

syntax of prototype function in C language


When a function is defined after the main function it needs to be declared in the declaration section of the program. This declaration section statement is known as function prototype.
This tells the calling function the type of value that will be returned with the name of the function and list of argument data types.

Syntax:
return type  function name(Argument list);
int fun (f1,f2);

Function with parameter with return


syntax of function with parameters and return value

This function can also return a value from the called function to the calling function i.e. the output which is printed in the main function whenever the value will be returned to the main function it can be printed thereafter. Now the function type should not be void because function will return a value. Therefore, it’s overall type is decided by the type of value it returned (int, float etc.).

Function with parameters with no return


syntax of function with argument with no return type in C language

Function can also use parameters and these parameters should be specified as a list along with function name with specific data types and each argument should be separated by ‘,’.
In function with parameter or arguments two types of arguments are used ACTUAL PARAMETERS and FORMAL OR DUMMY PARAMETERS.

Function without parameters in C-language


function defining syntax banner without parameters in C language

Such functions are defined same with return type followed by used defined name and a pair of parenthesis () and a block of codes. These functions uses two type of variables AUTOMATIC STORAGE CLASS VARIABLES and GLOBAL VARIABLES.

Function in C-language



function syntax of defining it header in C and C++ language


A function is block of codes that performs a particular task, this block is given a name and whenever we want to execute this block we simply write the name of the function. Function is a small sub-program which is a self contained block of statements and the function which is defined by the user is User Defined Functions.

Arrays in C-language


chess array banner with king and queen

Array is an arrangement of same type of data at adjacent memory locations. Array is useful whenever large volume of data is to be processed and stored in the memory.

Suppose an average marks are to be calculated from all the students in the school. This is difficult to find the sum of marks of all students. In this situation an array is the best alternative. Its divided in two categories:

1. Single / 1-D Array
2. Multi-dimension Array

January 21, 2013

Switch Statement


switch statement banner ON OFF


This statement is also used for decision making. Here key word is switch followed by control variable and followed by it’s block.
In the block of switch statement multiple cases are used and each ends with break statement this is also called as early exit loop.
Out of all the cases only that case will run whose value matches with the control variable.

Loop Control- Nested for loop


/*Program to print star matrix of order (4*5) */

#include<stdio.h>
#include<conio.h>
void main()
{
     int i,j;
     for(i=0;i<4;i++)
     {
                     for(j=0;j<5;j++)
                     {
                                     printf("*");
                                     }
                     printf("\n");
                     }
     getch();
     }
output of 4*5 star matrix using nested for loop in C language

Loop Control- for loop


loop control statement banner of for loop

“for” loop is also structure control loop as program will run or execute if the initial condition is true otherwise it will terminate and program will run until some condition is fulfilled.

FORMAT:
for(expression1;expression2;expression3)
{
Statement1;
Statement2;
}

Loop Control- While & Do while loop


loop control statements banner of while and do while loop

These are used for repeating some portion of the program either by specified number of times or until a particular condition is true.
1. while statement
2. do while statement
3. for loop

Decision making- Nested If else


decision making banner of nested if else statement

This statement can be used to select any one statement or a block which contains a set of instructions. Only that statement will execute which is true according to the data entered and rest other conditions will not executed.

FORMAT:
if(expression1)
Statement1;
else if(expression2)
statement2;
else if(expression3)
statement3;

Decision making- If else statement

decision making banner in if-else statement


This statement is also a conditional statement. It starts with keyword ‘if’ followed by an expression followed by “ first statement”  and “ second statement” is given after ‘else’ clause.

Format:
if(expression)
statement1;
else
statement2;

Decision Making- If statement

decision making banner in if statement



It is used whenever any condition is to be implemented by the user it means some conditions like:
1. If the price of the item is more than 5000 then discount is 10%.
2. If the students marks are greater than 60% then he should be in 1st division.

January 20, 2013

Simple C-programs


/*Program to enter two numbers by user and perform addition and multiplication operations*/

#include<stdio.h>
#include<conio.h>
void main()
{
     int n1,n2,sum=0,mul=0 ;
     printf("\n enter any two numbers");
     scanf("%d%d",&n1,&n2);
     sum=n1+n2;
     mul=n1*n2;
     printf("\n sum of two numbers is %d",sum);
     printf("\n multiplication of two numbers is %d",mul);
     getch();
     }
output of sum and multiplication of two numbers