Friday, 6 February 2015

Const Variable in C++

Structure of the Problem Requirements 

Const values are the static values that can't the change through out the program. The purpose of this is to secure programming and avoid programming mistake which occur due to logic error.

Source Code

#include <iostream>
using namespace std;
int main( )
{
int const a = 120;
const int b = 786; // DOES'N MATTER YOU DEFINE CONST BEFORE DATA TYPE OR AFTER
int sum = a+b;
cout<< " The 1st Const Number is : "<<a<<endl;
cout<< " The 2nd Const Number is : "<<b<<endl;
cout<<" The SUM OF BOTH NUMBER IS : "<<sum<<endl;
}

Output of the Program

Const Variable in C++

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment