Sign in to follow this  

Debug this

This topic is 4559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <iostream> using namespace std; int whatisthis( int c , int d ); int main() { } int whatusthis(void) { cout<<"what is your x value?"; cin>>value; return value; } why doesn't this work?

Share this post


Link to post
Share on other sites
Is it anything to do with the fact that you have declared a function whatisthis and then made a function whatusthis that hasn't been declared. Plus if this is a typo then you've said that whatisthis takes two integer parameters thus the actual function definition should take two integer parameters also.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
that and you use the variable value with declaring it..

Share this post


Link to post
Share on other sites
So maybe the code should be thus

#include <iostream>

using namespace std;

int whatisthis( int c , int d );


int main()
{

}


int whatisthis(int c, int d)
{

cout<<"what is your x value?";
cin>>value;

return value;

}

Share this post


Link to post
Share on other sites
Too many things were wrong with what you had. Here's what it should look like with full functionality.


#include <iostream>
using namespace std;
int whatisthis();
int main()
{
int x;
x = whatisthis();
cout << x;
return 0;
}


int whatisthis()
{
int value;
cout << "what is your x value?";
cin >> value;

return value;
}





EDIT: I love how this topic got 5 posts in about a single minute.

Share this post


Link to post
Share on other sites

This topic is 4559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this