#include <iostream>
int main ()
{
int a;
int b;
int sum;
cout<<"enter the first value\n";
cin>>a;
cout<<"enter the second value\n";
cin>>b;
sum = a + b;
if (sum == 3)
{
cout<<" you won ";
}
return 0;
}
My program not working help please.
Page 1 of 12 Replies - 149 Views - Last Post: 22 January 2013 - 07:00 PM
#1
My program not working help please.
Posted 22 January 2013 - 04:39 PM
I was trying to create like a test thingy but it's not working (im pretty new to c++ still). help please.
Replies To: My program not working help please.
#2
Re: My program not working help please.
Posted 22 January 2013 - 05:06 PM
You have omitted the line
using namespace std;
to allow you to reference cin and cout.
BTW Your post-title should be more descriptive in future (most people will be posting code that doesn't work in some way).
using namespace std;
to allow you to reference cin and cout.
BTW Your post-title should be more descriptive in future (most people will be posting code that doesn't work in some way).
#3
Re: My program not working help please.
Posted 22 January 2013 - 07:00 PM
cout and cin are defined in namespace std, think of a namespace as a big bag.
You can open the bag completely in the current scope, allowing you to use everything defined in the std namespace within that scope.
This is done by including
Or you can reach in the bag whenever you need something defined within the std namespace (preferred method)
The second method is preferred because it will avoid name clashing with other namespaces.
You can open the bag completely in the current scope, allowing you to use everything defined in the std namespace within that scope.
This is done by including
using namespace std; //the namespace is visible to main
int main() {
cout<<"Test";
Or you can reach in the bag whenever you need something defined within the std namespace (preferred method)
int main() {
std::cout<<"Test";
The second method is preferred because it will avoid name clashing with other namespaces.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|