Thread: help :S
View Single Post
Join Date: Nov 2008
Posts: 91
Reputation: brechtjah is an unknown quantity at this point 
Solved Threads: 9
brechtjah's Avatar
brechtjah brechtjah is offline Offline
Junior Poster in Training

Re: help :S

 
0
  #3
Nov 20th, 2008
If you want to use cout and cin you'll have to include <iostream> and use namespace std.
A sample program is something like this:

  1. #include <iostream>
  2.  
  3. int main() {
  4. int x, y, z, min; // Don't forget you can declare multiple variables of the same type on the same line
  5.  
  6. std::cout<<"Enter 3 numbers: ";
  7. std::cin>> x >> y >> z; // When entering the three numbers you have to leave spaces between them here
  8.  
  9. min = x;
  10. if (y<x && y<z)
  11. y=min;
  12.  
  13. if (z<x && z<y)
  14. z=min;
  15.  
  16. std::cout<<"min is : " << min << std::endl; // This prints text with the first insertion operator '<<', and a variable with the second
  17. // I added an endline for the beauty of it
  18.  
  19. system("pause"); // Pauses the application
  20. return 0;
  21. }

It's really not that hard, a good site would be: http://www.java2s.com/Tutorial/Cpp/0...0040__cout.htm
By the way, why give void as an argument to main?

Hope this helps, if you have any questions just post them ^^

EDIT: bah, Ancient Dragon beat me to it
Last edited by brechtjah; Nov 20th, 2008 at 8:29 pm.
Reply With Quote