Posts

Showing posts from May 27, 2018

C++ Program To Find The Area Of Triangle And Circle | C++ Programming

C++ Program To Find The Area Of Triangle And Circle 

C++ Program using Manipulators endl and setw | C++ Programming

C++ Program using Manipulators endl and setw Before starting the program let us know about the use of endl and setw which are called manipulators. Manipulators: It is one of the code used in C++ Programming Language to give nice appearance to the output of the code. The effect of these manipulators are only known when we execute the program and look for output. setw : It is used to give white space in the C++ program like setw(15): which means 15 white spaces. Syntax for setw: setw ( x ) endl: It is used for terminating the line. For Ex, we use "\n" in C program for new line like wise we use endl for new line in C++ Programming Language. //Create a model of mark sheet with equal gaps(using setw() function) and line change (using endl). Source Code #include<iostream> using namespace std; #include<iomanip> int main() { int a,b,c,d,e,total; float percent; cout<<"Enter marks of Maths:\n"; cin>>a; cout<<"E

Function overloading in C++ | C++ Programming

Function overloading in C++ Programming Overloading refers to the use of the same thing for a different purpose. When the same  function name is used for different tasks this is known as function overloading. Function overloading is one of the important features of C++ and any other OO languages. When an overloaded function is called the function with matching arguments and return type is invoked. e.g. void border(); //function with no arguments void border(int ); // function with one int argument void border(float); //function with one float argument void border(int, float);// function with one int and one float arguments  For overloading a function prototype for each and the definition for each function that share same name is compulsory. //function overloading //multiple function with same name #include&lt;iostream.h&gt; #include&lt;conio.h&gt; int max(int ,int); long max(long, long); float max(float,float); char max(char,char); void main() {   re

Passing and Returning by reference | C++ Programming

Passing by references in C++ Programming          We can pass parameters in function in C++ by reference. When we pass arguments by reference, the   formal arguments in the called function become aliases to the   actual arguments in the calling   function i.e. when the function is working with its own arguments, it is actually working on the original data.

Default Arguments and Constant Arguments

Default Arguments In C++ a function can be called without specifying all its arguments. In such cases, the function assigns a default value to the parameter which does not have a matching argument in the function call. The default value is specified when function is declared.  

Reference Variables | C++ Programming

Reference Variables:               C++ Programming introduces a new kind of variable known as reference variable. A reference variable provides an alias (Alternative name) of the variable that is previously defined. For example, if we make the variable sum a reference to the variable total, the sum and total can be used interchangeably to represent that variable.   Syntax for defining reference variable Data_type & reference_name = variable_nane   Example: int total=100 ; int &sum=total;                Here total is int variable already declared. Sum is the alias for variable total. Both the variable refer to the same data 100 in the memory.   cout< <total;    and  cout<<sum; gives the same output 100.   And total= total+100;   Cout< <sum;     //gives output 200                   A reference variable must be initialized at the time of declaration. This establishes the correspondence between the reference and the data object which it means. The initi

Scope Resolution Operator( :: ) | C++ Programming

Scope Resolution Operator( :: ) | C++ Programming C++ programming supports a mechanism to access a global variable from a function in which a local variable is defined with the same name as a global variable. It is achieved using the scope resolution operator ::  

Advantages and Disadvantages of OOP | C++ Programming

Advantages and Disadvantages of OOP Advantages of OOPs Object oriented programming contributes greater programmer productivity, better quality of software and lesser maintenance cost.  The main advantages are: Making the use of inheritance, redundant code is eliminated, and the existing class is extended. Through data hiding, programmer can build secure programs that cannot be invaded by code in other parts of the program. It is possible to have multiple instances of an object to co-exist without any interference. System can be easily upgraded from small to large systems. Software complexity can be easily managed. Message passing technique for communication between objects makes the interface description with external system much simpler. Aids trapping in an existing pattern of human thought into programming. Code reusability is much easier than conventional programming languages. Disadvantages of OOPs Compiler and runtime overhead. Object oriented progr