Showing posts with label what is const values in C. Show all posts
Showing posts with label what is const values in C. Show all posts

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