Const Variable in C++
Cplusplus, what are the Const Variable C, what is const values 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
0 comments:
Post a Comment