Game Programming



Visit Base Classics - Gaming Chairs

 
game programming
Game Programming :: Programming :: General Programming :: Code Examples :: [C++]Basic Input/Ouput - View Topic
Topic Rating: *****
Printable View
Andy
Administrator
*****

Posts: 40
Status: Offline
Gender: Male
Joined:  
pm

Reputation: 0%

[C++]Basic Input/Ouput (11th Jan 08 at 1:56am UTC)
Level: Beginner (no-experience)

This code asks for various number values entered from the keyboard and displays them back to the user

Code:
 
  1. //Basic Input/Output
  2.  
  3. #include<iostream>
  4.  
  5. int main()
  6. {
  7. int age = 0;
  8. float salary = 0.0;
  9. long distance_to_the_moon = 0;
  10.  
  11.  
  12. cout << "Type the employee's age and press the Enter Key:";
  13. cin >> age;
  14.  
  15. cout << "The employee's age is " << age << " years old" << endl;
  16.  
  17.  
  18. cout << "Type the amount of money the employee makes and"
  19. << " press the Enter Key:";
  20. cin >> salary;
  21.  
  22. cout << "The employee makes $" << salary << endl;
  23.  
  24.  
  25. cout << "Type the distance to the moon in miles and press the"
  26. << " Enter Key:";
  27. cin >> distance_to_the_moon;
  28.  
  29. cout << "The moon is " << distance_to_the_moon << " miles from"
  30. << " the earth" << endl;
  31. }
  32.  
 
 Printable View

All times are GMT+0 :: The current time is 7:55am
Page generated in 0.5202 seconds
Purchase Ad-Free Credits
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums