Here is the snippet of code I am having issues with.

    cout<<"So are you a male or female,  Please type m/f"<<endl;
    cin>>sex;

    if (sex='M','m') 
    {
    alcohol_distribution=.73;
} 
    else if (sex='F','f') 
    { 
    alcohol_distribution=.66;
}

So I know I have this terribly wrong, but i want the alcohol_distribution based on whether or not the user is a male or female. thank you very much.

Recommended Answers

All 2 Replies

if (sex=='m' || sex == 'M') { /* ... */ }

Note the use of == rather than = and the use of ||.

thank you so much that helped perfectly!:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.