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         ...