Friday, 22 May 2015
22:03
Using namespace std in Dev C++
Using namespace std :
Its clear from the above that the phase is having three words:-
using- means using what??
namespace - means using a namespace
Std - it is a kind of namespace
Therefore, the phase defines using a namespace of kind std.
Why to use it ??
The built in C++ library routine are kept in the standard namespace. That includes stuff like cout, cin, string, vector, map etc. Because these tools are used so commonly, it's popular to add" using namespace std " at the top of your code source code so that you won't have have to type the std:: prefix contantly before cout, cin etc.
Its clear from the above that the phase is having three words:-
using- means using what??
namespace - means using a namespace
Std - it is a kind of namespace
Therefore, the phase defines using a namespace of kind std.
Why to use it ??
The built in C++ library routine are kept in the standard namespace. That includes stuff like cout, cin, string, vector, map etc. Because these tools are used so commonly, it's popular to add" using namespace std " at the top of your code source code so that you won't have have to type the std:: prefix contantly before cout, cin etc.
21:48
About Dev C++
Dev C++ - Developer C++ is an advanced C++ IDE ( Integrated Development Environment) which has some xtra advanced faetures as compared to other IDEs like Turbo C++, Borland C++ etc.
Dev C++ also comes in little changes in normal syntaxs.
Dev C++ Vs Other IDEs :
Dev C++ also comes in little changes in normal syntaxs.
Dev C++ Vs Other IDEs :
- In Dev C++, Header File "iostream" is declared without extension ".h"(dot h).
- In Dev C++, after Header File declaration , it is required to write a statement 'using namespace std' .
- In Dev C++, the return type of the main funtion cannot be 'void'. By deafult the return type is 'int'.
- In Dev C++, there is no functions like clrscr() (clear screen). Instead of clrscr(), system("cls") can be preferred.
- In Dev C++, memory bytes "int" datatype is 4 byte where as in Other IDEs is 2 byte.
21:47
Main Function
Main Funtion is a function from where the execution of the program starts. It is the first function that is called to perform other operation like calling of other functions etc.
Every C++ program must contain a main function. This means that a main function is a mendatory and necessary funtion and an important one.
Syntax:-
return_type main ()
{
// body
}
return_type can be void, int, float, char & double. By default the return type of main function is int (integer)
Every C++ program must contain a main function. This means that a main function is a mendatory and necessary funtion and an important one.
Syntax:-
return_type main ()
{
// body
}
return_type can be void, int, float, char & double. By default the return type of main function is int (integer)
Tuesday, 5 May 2015
09:45
Header files and their in-built function - 2
2. conio.h - Header File
Syntax:- #include<conio.h>
This is one of most important header file used in C++ after iostream.h. It means CONSOLE INPUT OUTPUT (con-io).
This header file include some of the important in-built functions like:
i. clrscr(): Full form is "Clear Screen".This functions is used to clear all the previous outputs generated by the program which are not of any use, from the console.
For example: If you run a program with some input and the program is generating some output, and after the termination of the program you tried to run another program without using clrscr(), the output of the program will be shown on the monitor along with the previous outputs of the program you tried last.
Note:- { clrscr() function is only applicable in the IDE like Turbo C++ and Borland C++ not in Dev C++. }
ii. getch(): Full form is "Get Character". This funtion is usually used to hold-on the screen or rather used to pause the flow of execution of the program until and unless you press any key from your input device such as keyboard, the execution will not go further.
There are many more in-functions like putch(), getche(), getchar() etc but above two are most important one.
Readers please do not get confuse about functions, they will be discuss later.
For any query and doubts please do drop it in the comment box. It will be pleasure to clearify your doubts.
Happy coding...
Syntax:- #include<conio.h>
This is one of most important header file used in C++ after iostream.h. It means CONSOLE INPUT OUTPUT (con-io).
This header file include some of the important in-built functions like:
i. clrscr(): Full form is "Clear Screen".This functions is used to clear all the previous outputs generated by the program which are not of any use, from the console.
For example: If you run a program with some input and the program is generating some output, and after the termination of the program you tried to run another program without using clrscr(), the output of the program will be shown on the monitor along with the previous outputs of the program you tried last.
Note:- { clrscr() function is only applicable in the IDE like Turbo C++ and Borland C++ not in Dev C++. }
ii. getch(): Full form is "Get Character". This funtion is usually used to hold-on the screen or rather used to pause the flow of execution of the program until and unless you press any key from your input device such as keyboard, the execution will not go further.
There are many more in-functions like putch(), getche(), getchar() etc but above two are most important one.
Readers please do not get confuse about functions, they will be discuss later.
For any query and doubts please do drop it in the comment box. It will be pleasure to clearify your doubts.
Happy coding...
08:58
Header files and their in-built functions -1
Header files are pre-coded error free programs which are included before the actual programs are written . They provide some in-built functions, classes etc which helps us to code , saves our time , make our programs from being too lengthy and hence decreases compilation/execution time.
1. iostream.h - header file
Syntax- #include<iostream.h> ( for Turbo and Borland c++)
#include<iostream> ( for DevC++)
"iostream" means input-output stream. The name itself says that this header file includes those in-built functions which perform the input-output operations, i.e, functions that helps to take input from the keyboard , process the input data and display the resulting output to the screen or console.
Note:-
{ Actually, iostream is an in-built class embeded/or packed in header file called iostream.h. }
One of the most important in-built function that this header file include is an operator overloaded function ">>" and "<<".
a. ">>" - Normally called Bitwise Right Shift Operator, othername Extraction Operator. It is an operator overloaded member function of the class iostream with an object "cin" (console input) with which you can take any kind and type of input(like numbers, characters, words, lines, paragraphs etc) from your keyboard.
Syntax:- cin>>INPUT FROM YOUR KEYBOARD;
b. "<<" - Normally called Bitwise Left Shift Operator ,othername Insertion Operator. It is an operator overloaded member function of the class iostream with an object "cout" (console output) with which you can take any kind and type output(like number, characters, words, lines, paragraphs etc) to your console/screen/monitor.
Syntax:- cout<<"OUTPUT TO YOUR MONITOR";
Note:- { Give output as letters, words, lines, paragraph or any character on screen, you must enclose it between Double Inverted Commas ("....") except variables and function calling( will discuss later.). }
Readers Please dont be confused about classes and functions, they will be discuss later. Till then just remember cin>> and cout<< are used for taking input and giving output respectively.
Monday, 4 May 2015
11:41
Format - Header File Declaration
Header files are the pre-compiled or pre-coded files with correct logic and syntax that includes in-built functions, class, structure etc. , which may directly or indirectly can be used in the program to avoid the program coding from being lengthy and hence make the execution time fast.
These files are stored in lib folder (library folder) of your respective IDE.
Header files comes with the extension ".h"(dot H).
For eg;
if XYZ is a header file then it comes with "XYZ.h".
Syntax to be used in program to use header file:
#include<XYZ.h>
#include-(hash include) This is called pre-processor directives which means that these are the codings which are already been compiled and processed by the IDE compiler.
#- It is used as linking and loading the header files i.e, it act as a interface between the library file and programming.
include- This includes all the in-built functions, class and structures which are packed in the header file closed in < ......>.
Mostly used header files in C++:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
These files are stored in lib folder (library folder) of your respective IDE.
Header files comes with the extension ".h"(dot H).
For eg;
if XYZ is a header file then it comes with "XYZ.h".
Syntax to be used in program to use header file:
#include<XYZ.h>
#include-(hash include) This is called pre-processor directives which means that these are the codings which are already been compiled and processed by the IDE compiler.
#- It is used as linking and loading the header files i.e, it act as a interface between the library file and programming.
include- This includes all the in-built functions, class and structures which are packed in the header file closed in < ......>.
Mostly used header files in C++:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
Sunday, 3 May 2015
10:46
Lets Start With C++ - a proper format
C++ coding is done on IDE- Integrated Development Environment. It is a software application that provides a platform to run ,compile and execute High Level Programming language.
For C++ the IDEs are Dev C++ (recommended), Turbo C++, Borland C++ etc.
Every IDE has compilers which compile the written codes and check the errors and verifies whether the codes are following the correct logic, syntax etc which are required to run and execute the program successfully.
Below are the following formats that are required to follow to make the programs(coding) syntaxtically.
1.Header File Declaration.
2.Function Prototyping.
3.Function Defination.
4.Main Function (most imporatant and compulsary).
~For any query and doubts please drop it in the comment box or email me. It will be a pleasure to solve and clear your doubts.
Happy coding...
For C++ the IDEs are Dev C++ (recommended), Turbo C++, Borland C++ etc.
Every IDE has compilers which compile the written codes and check the errors and verifies whether the codes are following the correct logic, syntax etc which are required to run and execute the program successfully.
DevC++ - an IDE
Turbo C++ 3.0 - An IDE
Borland C++ - an IDE
Below are the following formats that are required to follow to make the programs(coding) syntaxtically.
1.Header File Declaration.
2.Function Prototyping.
3.Function Defination.
4.Main Function (most imporatant and compulsary).
~For any query and doubts please drop it in the comment box or email me. It will be a pleasure to solve and clear your doubts.
Happy coding...
10:30
Concepts Of OOP (Object Oriented Programming) - An Idea
Later, we discussed about the features of Object Oriented Programming (OOP). In this chapter, we are going to learn about the concepts that can be implemented by this paradigm, not in detail but a mild touch. We will be doing this in detail in the upcoming blog.
CONCEPTS:-
1. Class and objects
2. Data Abstraction
3. Encapsulation and Data binding
4. Data Hiding
5. Polymorphism and overloading
6. Inheritance and reuse-ability
7. Dynamic binding
8. Message passing
These concepts of OOP enable us to modify, give security and new mode of programming to our program.
These concepts we are going to deal, when we will be handling with "class".
Till then do remember these features and concepts.
~For any query and doubts please drop it in the comment box or email me. It will be a pleasure to solve and clear your doubts.
Happy coding...
CONCEPTS:-
1. Class and objects
2. Data Abstraction
3. Encapsulation and Data binding
4. Data Hiding
5. Polymorphism and overloading
6. Inheritance and reuse-ability
7. Dynamic binding
8. Message passing
These concepts of OOP enable us to modify, give security and new mode of programming to our program.
These concepts we are going to deal, when we will be handling with "class".
Till then do remember these features and concepts.
~For any query and doubts please drop it in the comment box or email me. It will be a pleasure to solve and clear your doubts.
Happy coding...
10:15
Why C++? - an Introduction
As the word defines itself "C + +" ,i.e "C Plus Plus" , quite similar like increment operator(++) in C, which means a step ahead of C language. This gives a whole picture that C++ includes all the features of C but along with it, it is a step ahead with new features.
As a whole we can say, C is the Subset of C++ ; where as C++ is the superset;
As a whole we can say, C is the Subset of C++ ; where as C++ is the superset;
The main feature of C++ that makes it differ from C is that it comes with Object Oriented Programming (OOP) paradigm where as C is a POP (Procedural Oriented Programming) or FOP (Function Oriented Programming).
OOP is a programming paradigm that enables to modularize the program by creating the memories for both data and functions that can be bind into one single unit and can used as templates and enables us to create such copies on demand.
OOP features;--
1.Follows bottom up approach.
2.More priority to data rather than procedure or algorithms.
3.Hide and give security to data from external user.
4.Data can only be fetched or access by what is known as methods or functions.
5.Program is divided into what is known as objects.
6.Functions may communicate with each other through objects.
POP is a programming paradigm that gives more priority to procedure or algorithms.
POP features:--
1.Follows top-down approach.
2.More priority to procedures and algorithms.
3.No security and data can be accessed by outside programmer.
4.Program is divided into functions.
5.Functions may communicate through functions.
So, from the above knowledge, we can conclude that C++ gives the flexibility to the programmers to use the language in both OOP and POP paradigms..
~For any query and doubts please drop it into the comment box or email me. It will be my pleasure to solve and clear your doubts.
Happy coding.....