Posts

C++ Input/Output : Streams

Image
In this article, you will learn about Streams Based Input/Output in C++ .The input/output operations which involve keyboard as input device and screen as output device are known as Console I/O operations . The input/output operations which involve file as input device and output device are known as File I/O operations C++ Input/Output implement concept of stream .It is an object-oriented alternative to C's FILE-based streams from the C standard library.Stream is the sequences of bytes or flow of data , which acts as a source from which the input data can be obtained by a program or a destination to which the output data can be sent by the program.
Input Stream :It is flow of data bytes from a device (e.g Keyboard , disk drive) to main memory Output Stream : It is flow of data bytes from main memory (i.e program) to a device
Stream Class Hierarchy
Stream class is the collection of data and the methods necessary to control and maintain flow of data or stream .These stream class are …

Exception Handling

Image
In this article, you will learn about Exception Handling in C++ and which handle run time error.
Exception Handling is the mechanism that separate the code that detects and handle exceptions at run time from rest of program C++ exception handling is built upon three keywords: try, catch, and throw.
Exception Handling vs Traditional Error HandlingFollowing are main advantages of exception handling over traditional error handling.
1) Separation of Error Handling code from Normal Code: In traditional error handling codes, there are always if else conditions to handle errors. These conditions and the code to handle errors get mixed up with the normal flow. This makes the code less readable and maintainable. With try catch blocks, the code for error handling becomes separate from the normal flow.
2) Functions/Methods can handle any exceptions they choose:A function can throw many exceptions, but may choose to handle some of them. The other exceptions which are thrown, but not caught can be ha…

Tempaltes

In this article, you will learn about Templates in C++ and it's useful for generic programming in C++.
Templates are a feature of the C++ programming language that allows single functions and classes to handle different data types. This helps you to write generic programs.
Generic ProgrammingGeneric programming is a style of computer programming in which program are not compiled as it is but rather 'Templates' of source code are transform into source code at the time of compilation according to supplied datatype as parametersIn Templates of C++ template of class or function is defined with general data type and is replaced by a specified data type at the time of actual use of class or function , Hence it follow Generic programming

An Example to Begin WithThis program add two number of different data type according to type of supplied argument
Output
Result of adding two float : 13.7 Result of adding two integer : 13

At the time of compilation 'a' is replaced by d…

Copy Constructor

In this article, you will learn about copy Constructor and where to use it. Also, you will learn about different troubleshooting related to it.

This constructor has an argument of an object of same type or same class as a reference.This constructor has an argument of an object of same type or same class as a reference. This constructor has an argument of an object of same type or same class as a reference.This constructor has an argument of an object of same type or same class as a reference. An Example to Begin WithThis constructor has an argument of an object of same type or same class as a reference.This constructor has an argument of an object of same type or same class as a reference. a add (a c , a d) { a sum ; sum = c + d ; return sum; }
Output
Loading weapon features. Loading bomb features. Loading gun features.
This constructor has an argument of an object of same type or same class as a reference.This constructor has an argument of an object of same type or same …

Defining a Structure

Defining a StructureDefining a Structure is a process of creating the skeleton of physical object that can be understood by compiler .It consists of Structure name and the description of it’s member(property).

Definition of a structure creates a template are format that describes the characteristics of it’s member .

The general syntax of a structure definition is:
Struct structurename{ Datatype member1; Datatype member2; ………………………………….. Datatype membern; };Here struct is a keyword , which tells the compiler that a structure is being defined . member1 , member2 ,………,membern are the member of structure and are declared inside curly bracket .
There should be a semicolon at the end of the curly braces

These member can be of any data type like int , char , float , array , pointer or another structure

Structurename is the name of the structure and is used further in the program to declare Structure var…

C program to find Transpose of Matrix.

Write a C program to find Transpose of Matrix  This C program prints the Transpose of supplied Matrix.
C Program source code#include<stdio.h> #include<conio.h> #define MAX 100 int main() {  int i,j,r,c,m[MAX][MAX];  printf("Enter the order of matrix:\n");  scanf("%d%d",&c,&r);  printf("Enter a %d*%d matrix:\n",c,r);  for(i=0;i<c;i++)  {   for(j=0;j<r;j++)   {    scanf("%d",&m[i][j]);   }  }  printf("Matrix before transpose:\n");  for(i=0;i<c;i++)  {   for(j=0;j<r;j++)   {    printf("%d\t",m[i][j]);   }   printf("\n");  }  printf("Matrix after transpose:\n");  for(j=0;j<r;j++)  {   for(i=0;i<c;i++)   {    printf("%d\t",m[i][j]);   }   printf("\n");  }  getch();  return(0); } You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment
DO NOT …

C program to check if the supplied year is leap year or not.

Write a C program to check if the supplied year is leap year or not.  This C program check if the supplied year is leap year or not.
C Program source code#include<stdio.h> #include<conio.h> int main() {  int y;  printf("Enter a year:\n");  scanf("%d",&y);  if(y%400==0)  {   printf("Its a leap year.");  }  else if(y%100==0)  {   printf("Its not a leap year,");  }  else if(y%4==0)  {   printf("Its a leap year,");  }  else  {   printf("Its not a leap year,");  }  getch();  return(0); } You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment
DO NOT MISS OTHER C PROGRAMMING TUTORIAL* indicates required Email Address *



C program to check if the supplied year is leap year or not.