Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

Const Variable in C++

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:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List