New to C++, need help

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2004
Posts: 193
Reputation: YoungCoder is an unknown quantity at this point 
Solved Threads: 2
YoungCoder's Avatar
YoungCoder YoungCoder is offline Offline
Junior Poster

Re: New to C++, need help

 
0
  #11
Aug 20th, 2004
Originally Posted by RobinA
ok i fixed it now but got one more question (heres the final code i used) when i click run the program it opens but it closes itself in about 0.01 sec after it have opened. whats the wrong now with the code, and i dont get any errors when compiling.

# include <iostream>
int main()
{
using namespace std;
int tal1, tal2, produkt;
tal1=5;
tal2=11;
produkt=tal1*tal2;
cout <<"Produkten är" << produkt;
}
I am a total newbie to c++ myself however i THINK its something like:

  1. # include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int tal1, tal2, produkt;
  6. tal1=5;
  7. tal2=11;
  8. produkt=tal1*tal2;
  9. cout <<"Produkten är" << produkt;
  10. cin >> mong;
  11. return 0;
  12. }

Basically it ends because it reached the end of the program, if you add an input to the end then the program isnt finished till you do the input.
I have not tested this and have no idea if it works, like i said im a c++ newbie too :o

YoungCoder
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #12
Aug 20th, 2004
YoungCoder i compiled the code and it didnt go it was cin that was the error but i erased that line ( cin >> mong then it worked like mine it opened and closed.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #13
Aug 20th, 2004
ok i got it to work now the final code was


# include <iostream>
using namespace std;
int main()
{
int tal1, tal2, produkt;
tal1=5;
tal2=11;
produkt=tal1*tal2;
cout <<"Produkten is " << produkt;
}

and i compiled it in Visual C++ now and it worked.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 19
Reputation: Pikachu is an unknown quantity at this point 
Solved Threads: 0
Pikachu's Avatar
Pikachu Pikachu is offline Offline
Newbie Poster

Re: New to C++, need help

 
0
  #14
Aug 20th, 2004
Other than using :-
#include <iostream>
using namespace std;

you can also try to replace it with this:-
#include <iostream.h>

But it is adviceable to use the former as it is of the latest format.
Good Luck!
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: New to C++, need help

 
0
  #15
Aug 21st, 2004
Yea,using #include <iostream> is now the latest standard.

namespaces are something like a sealed off area of code,out side which you can use the same names with out conflicting with the name in the namespace scope.

You can also access namespace vars like namespace::std, std::cout

Have fun,ALSO learn to use the Standard Template Library (STL)
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 3526 | Replies: 14
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC