RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 2923 | Replies: 14 | Thread Tools  Display Modes
Reply
Join Date: Aug 2004
Posts: 177
Reputation: YoungCoder is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 2
YoungCoder's Avatar
YoungCoder YoungCoder is offline Offline
Junior Poster

Solution Re: New to C++, need help

  #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:

# include <iostream> 
using namespace std;
int main()
{ 
int tal1, tal2, produkt;
tal1=5;
tal2=11;
produkt=tal1*tal2;
cout <<"Produkten är" << produkt; 
cin >> mong;
return 0;
}

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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Posts: 9
Reputation: RobinA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RobinA RobinA is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: Aug 2004
Location: Malaysia
Posts: 19
Reputation: Pikachu is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Pikachu's Avatar
Pikachu Pikachu is offline Offline
Newbie Poster

Re: New to C++, need help

  #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  
Join Date: May 2004
Posts: 253
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Rep Power: 6
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: New to C++, need help

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the C++ Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:56 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC