Posts

Include Vs Import

Image
There are two terms IMPORT and INCLUDE ,  In C and C++ Programs ,  Include Statement is used #include directive makes the compiler go to the C/C++ standard library  It copy the code from the header files into the program.  The whole include file code will copy into the program  As a result, the program size increases wasting memory and processor’s time.  In Java Programs , Import  Statement is used import statement makes the JVM(Java Virtual Machine) go to the Java standard library, execute the code there ,  and substitute the result into the program.  Hence, no code is copied hence no waste of memory and processor’s time. Hence import is more efficient mechanism than #include. By - Somesh Sah

Function Overloading

Image
  Function Overloading -  " Multiple Definition of a function with in same scope having different signature are called Function Overloading   " Signature of a function- Number & Type of a parameter of a function is called signature of the function. Question - Write an overloaded function area which will print the area of circle,rectangle and square. Program - #include<iostream> using namespace std; //function prototype  int area(int); int area (int,int); double area (double); int main(){ cout<<"Calling area with 5cm side : "<<area(5)<<endl; cout<<"calling area with l=5,b=10 : "<<area(5,10)<<endl;   cout<<"calling area with 5.5cm radius : "<<area(5.5); return 0; }  //Area of square  int area (int side){ return (side*side); } //area of rectangle int area(int length ,int breadth){ return (length * breadth); }  //area of cir...

Object Oriented Program (Paradigm)

Image
Paradigm - It is a mythology and implementation of the program. (It is a way of programming) Therefore, There are three ways (Style) to write a program - ♣ Procedural Programming  ♣ Object Based Programming ♣ Object Oriented Programming  Procedural Programming -  ☻ Importance is given to the procedural (Function and Methods) ☻ Data is secondary ( data moves openly) ☻ It follows Top-Down Designing. Example - Basic and C  Object Based Programming - ☻ These languages support Classes  ☻ These languages does not support Inheritance and Polymorphism    Example - ada Object Oriented Programming - ☻ These language support all the mentioned features Encapsulation Abstraction Polymorphism Inheritance ☻ Data is hidden ☻ It follows bottom up design  Example - C++ , Java etc. Now, Object Oriented Programming (OOP's) in detail  DEFINITION OF OOPs " O...

Some Useful Functions

Image
typedef ◘ It is used to give another name to the previous or existing data type. ◘ It is not creating new data type. ◘ typedef data_type another_name ; Example- #define ◘ It is also called compiler directive. ◘ It is also called pre-processor ◘ It is used to define Symbolic constants. ◘ #define pi 3.14; ◘ It is also used to define mricros (small single line statement function) Example of micros, #include ◘ It is used to add contains of a file which is written inside the angular bracket < > . Example -               #include <iostream> * It will help to include fine iostream in our program. #if ◘ It is used to test whether a compiler time condition is true. #under ◘ It is used to un-define micros. #else ◘ It is used to specify the alternative . ◘ It used to perform an action if a test fail. #endif ◘ To end the pre-processor conditions. By - Somesh Sah

Structure

Image
In C++  " It is a collection of variables referred under one name.  " Structure can be Defined as - - struct is the keyword. - structure is a collection of related data types known as a members of structure. - It is very powerful. - In array , we group of same data type but in structure we can able to group different data types. - structure is always end up with a (;) semicolon . Now we have to makes the object of the structure student [ name_of_the_structure obj; ] Object -  - Is an run time entity. - It contains all the members and its functions - we can not use structure without making its object. - object of student S1 . - S1 has its own name , roll number and percent.  - like that we can create as many as objects. Note - The Members of the object can be assessed bu using ( . ) dot operator. Ques - Write a program to make a structure to enter book name and its author name then dis...

Array

Image
"Array - It is a collection of variable of same data type and referred under a common name." In C++ ,  the declaration of an array is  int a [10] ;                  where  int is a Data Type , it can b float, char etc.  a is a Name of the Array (under which it is referred) [ index number ] is a size of array and it is always started from 0 to size-1 . Two Types Of Array ♣ Single Dimensional Array  ♣ Two Dimensional Array ♣ Multi Dimensional Array # Single Dimensional Array - it store its elements in linear form. - it has continuous memory location. - the size of array is always positive.   Here we declarer an array with size of 5 elements. ( int a[5]; ) a[5] = {55,45,78,67,28} a[0] = 55 a[1] = 45 a[2] = 78 a[3] = 67 a[4] = 28 Note- 5001 , 5002, .... 5005 is know as address of the array elements (store in...

User defined Function

Image
" Function is defined as a group of statements that together perform a specific task. " - Main() is a function, therefore every C++ program should have at least one function. - Function is divided into 3 part           1 - function declaration          2 - function definition          3 - function call  - A function declaration tells the compiler about a function's name, return type, and parameters. - A function definition means body of the function. - A function call  is a part of main programs and it specified which function should be called. Example - There are four possible style to write a function in your program - 1- void function with no argument                      e.g- 2- void function  with argument         ...

Call By Value & Call By Reference

Image
FORMAL PARAMETER - These are the parameters which appear in the function definition or declaration is called Formal Parameter.  ACTUAL PARAMETER - These are the parameters which appear in the function call is called Actual Parameter. Call By Value - In Call By Value , value of actual parameter is copied into Formal Parameter. The function work on formal parameter only. Actual parameter is intact. Change are not reflected is called function. Call By Reference -  In this type, instead of copying a value of actual parameters into formal parameter, the function receive address of the actual parameter. Works on the original value, Changes are reflected in the calling function. Summary -    By - Somesh Sah

Nested Loop

Image
"In Computer Science a nested loop is a loop within a loop, an inner loop within the body of an outer loop." How this works is that the first pass of the outer loop triggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again.  This repeats until the outer loop finishes. 0r In Simple Words -  consider yo have to plot a graph , so you need (x,y) point... Similarly the outer for loops provide you x values and the inner for loop provides y values. Of course, a break within either the inner or outer loop would interrupt this process. The concept of Nested loop is very Important. Nested loop is very useful in Advance programming. Syntax - For Example - Please watch this video ...to understand nested loop clearly. Generally Nested Loops used in pattern programming... Please follow this link - http://www.programiz.com/article/c%2B%2B-programming-pattern ...

Loop Statement Programs

Image
  " In computer programming, a loop is a sequence of instruction that is continually repeated until a certain condition is reached " There are three types of loops ♣ for loop ♣ while loop ♣ do while loop FOR LOOP Defination - For loop is used for counting purpose. - For loop is divided into three parts 1- initialization 2-  condition 3- increment/decrement Initialization is that part of the loop where counting starts. Condition is that part of the loop which defines the end point of the counting till it satisfy the parameter(condition) Increment/Decrement is that part of the loop which defines the order of counting in increment/decrement order. Syntax of for loop for(initialization; condition; increment/decrement) { Statements ; } Programming (Example) Ques - Display the number from 0 to 9 using for loop Output WHILE LOOP - WHILE loops are very simple. - If conditions is true ...

Standard Library Functions

Image
According to wikipedia ... Standard stands for a level of quality or attainment.       Library stand for collection of book. Function is an activity that is for a purpose of a person or thing. Therefore The Standard Library Functions  are defined as  ... "Standard Library are the collection of subprograms (function) which is used to develop other programs or software." ♥ Types of Functions 1- Library Functions  (Header Files function)                         //In this post 2- User Defined Function (User Defined Functions)               // In next post ♣ Character Functions Character Functions, are the collection of all the function related with characters. The header file is "ctype.h" is used to use following functions. # isalnum() - is - " Is " is used to form question. al-   al stands " alphabet " . num...