Advertisement
BaSs_HaXoR

First day of C++ programming [College]

Jan 14th, 2015
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. //My first day of C++ Programming...
  2.  
  3. // pgm1.cpp - My C++ program
  4. #include<iostream> //include in/output of the actual program
  5. using namespace std; //include namespace so you don't have to keep using std:: before the functions in the class
  6.  
  7. int _age; //global variable that can be used throughout the scope of the program
  8.  
  9. int main() //scope of program
  10. {
  11.     /*
  12.     int x = 0;
  13.     char y;
  14.     float z;
  15.     long a;
  16.     double b; //these are variables
  17.    
  18.     std::cout<< "int x = " << sizeof(x) << std::endl;
  19.     std::cout<< "char y = " << sizeof(y) << std::endl;
  20.     std::cout<< "float z = " << sizeof(z) << std::endl;
  21.     std::cout<< "long a = " << sizeof(a) << std::endl;
  22.     std::cout<< "double  b = " << sizeof(b) << std::endl;
  23.     //std can be removed as it's added throughout the scope of the entire program
  24.     std::cin.get();
  25.    
  26.     cout<<"hello, how old are you?: ";
  27.     cin >> _age; //age is entered here
  28.     cout<< "You are: "<<_age <<" years old";
  29.    
  30.     cin.get();
  31.     cin.get();
  32.     */
  33.    
  34.     cout<<"Enter your age: "; //cout = text outputted to console
  35.     cin >> _age;
  36.     int date = 2014; //int is allocated to 4 bytes in memory in RAM
  37.     int outcome;
  38.     outcome = date - _age;
  39.     cout<<"You were born in the year: " << outcome;
  40.     cin.get(); //Waits for user input
  41.     cin.get();
  42.    
  43.     return 0;
  44. }
  45. //I already knew a lot of the stuff already, but thought I would share. :D
  46. //BaSs_HaXoR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement