Guest User

How to declare constant's name.

a guest
Feb 2nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. 1) By using #define keyword :-
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. #define ALL 20
  6. #define SOME 39
  7. int main ( )
  8. {
  9. int a;
  10. a=ALL+SOME;
  11. cout << a;
  12. return 0;
  13. }
  14.  
  15. 2) By using const keyword :-
  16.  
  17. #include <iostream>
  18. using namespace std;
  19. int main ( )
  20. {
  21. int a;
  22. const int ALL = 22;
  23. const int SOME = 30;
  24. a= ALL+SOME;
  25. cout << a;
  26. return o;
  27. }
  28.  
  29.  
  30.  
  31.  
  32. For more visit: http://houseofprogramminglanguages.blogspot.com/
Add Comment
Please, Sign In to add comment