C++ const Create Constant Values

Description

C++ const Create Constant Values

#include <iostream> 

using namespace std; 

const int MyValue = 80; 
const string StoreName = "My Store"; 
const float pi = 3.1415926; 

int main() /*from ww  w .  j a  va2s .  c o m*/
{ 
    cout << "Here at " << StoreName << endl; 
    cout << "we believe you should know" << endl; 
    cout << "that we have " << MyValue; 
    cout << " full-sized" << endl; 
    cout << "parking spaces for your parking" << endl; 
    cout << "pleasure." << endl; 
    cout << endl; 

    cout << "at " << StoreName << endl; 
    cout << "spaces from " << MyValue << " to "; 
    cout << MyValue * 2; 

    float radius = 5; 
    float area = radius * pi * pi; 

    cout << "And remember, we sell " << radius; 
    cout << " inch apple pies" << endl; 
    cout << "for a full " << area << " square" << endl; 
    cout << "inches of eating pleasure!" << endl; 

    return 0; 
}



PreviousNext

Related