help :S

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 5
Reputation: mstrofdrgns is an unknown quantity at this point 
Solved Threads: 0
mstrofdrgns mstrofdrgns is offline Offline
Newbie Poster

help :S

 
0
  #1
Nov 20th, 2008
hey there ,

Im taking C++ courses in my collage (so ım a newbie) and they are teaching programing language a bit different from the examples in this forum.
  1. #include <stdio.h>
  2.  
  3.  
  4. int main (void)
  5. {
  6. int x;
  7. int y;
  8. int z;
  9. int min;
  10. printf("enter 3 numbers : ");
  11. scanf("%d %d %d", &x,&y,&z);
  12.  
  13. min=x;
  14. if (y<x && y<z)
  15. y=min;
  16. if (z<x && z<y)
  17. z=min;
  18.  
  19. printf("min is : ", min);
  20. return(0);
  21. }
well this works too, but ı can not understand most of the programs in this forum

is there any place to learn how to write that " cout << ".... ; " thing or something like this
ty for helping this newcommer


/* sorry for my bad english ı hope u could understand what ı meant */
Last edited by Ancient Dragon; Nov 20th, 2008 at 8:22 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,433
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: help :S

 
0
  #2
Nov 20th, 2008
That is C code, not C++. Are you sure you are in a c++ class?

for a fstream tutorial click here.

cout is quite easy to learn. First you have to include <iostream> header file -- it does not have a .h extension. Then declare the std namespace.
  1. #include <iostream>
  2. using std::cout;
  3.  
  4. int main()
  5. {
  6. cout << "Hello World\n";
  7. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
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 Quick reply to this message  
Join Date: Nov 2008
Posts: 5
Reputation: mstrofdrgns is an unknown quantity at this point 
Solved Threads: 0
mstrofdrgns mstrofdrgns is offline Offline
Newbie Poster

Re: help :S

 
0
  #4
Nov 20th, 2008
ty for your replies.

Originally Posted by Ancient Dragon View Post
That is C code, not C++. Are you sure you are in a c++ class?
well, i am taking introduction to programing class and they are telling us that " we are teaching you c++" but im not so sure about this now

Originally Posted by brechtjah View Post
By the way, why give void as an argument to main?
i have no clue about this they just tought us to do that this way and when i ask assistants about it, they just dont explain us clearly .

ty again
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,433
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1471
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: help :S

 
0
  #5
Nov 20th, 2008
void main(). C and C++ standards require main() to return an int.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC