need help debugging this program

//DEBUG1 Program
//This program asks the user for a stock number, then validates it.
//A stock number between 200 and 800 inclusive is valid.


#include<iostream>
#include<string>
using namespace std;


int main()
{
int stockNum;
int validateNum(int stockNum);
cout<<"\nPlease enter stock number ";
cin>>stockNum;
if (validateNum(stockNum =1))
cout<<"\nValid number";
else
cout<<"\nInvalid number";
}



int validateNum(int stockNum)
{
int validCode = 0;
if(stockNum>=200 && stockNum<=800)
validCode=1;
system("pause");

return(stockNum);
Why are you assigning 1 to stockNum when you try to pass it to validateNum?
When I change it to if(validateNum(stockNum==1)).. The result always comes back as invalid..
Why not try something like this
1
2
3
4
5
6
7
8
9
If (stocknum>=200){
If (stocknum<=800){
cout<<"valid";
Else
cout<<"invalid";
}
Else 
court<<"invalid";
}

I'm on my phone, sorry for any syntax errors, but you should get the point.
@dariusd7 remove the =1 / ==1 thing entirely, that's not how you call a function.
Topic archived. No new replies allowed.