if (a==b && a > 1 || a < 31 && b > 1 || b < 31)
cout << "true";

from what i can understand I've told the compiler that if
a is equal to b and a is greater than 1 or less than 31 and B is lso greater than 1 or less than 31 print true

however if you enter 33, 33 true is also displayed!! yet its out of the range i specified ...

anyone know why?

haha i solved it:
if (a==b && a > 1 && a < 31 && b > 1 && b < 31)

werid though since its only a guess!

Can you post some more code? Where are you introducing a and b?
--------------------
Doesn't matter... I saw your edit...

Can you post some more code? Where are you introducing a and b?

werid now I've tried to make it better ...and ...

if (a==b && a > 1 && a < 31 && b > 1 && b < 31){
		cout << "The day matches\n";
}
	else if
	
		(a==b && a < 1 && a > 31 && b < 1 && b > 31){
	cout << "error in date. Please check your date and re enter.";
	}

	else if
	
		( a != b && a > 1 && a < 31 &&  b > 1 && b < 31){
		cout << "your dates don't match";
	}

now the middle if else doesnt work

else if (what???)
	{
	(a < 1 && a > 31 && b < 1 && b > 31);
		cout << "error in date. Please check your date and re enter.";
	}

	else if (what???)
	{
	( a != b && a > 1 && a < 31 &&  b > 1 && b < 31)
	cout << "your dates don't match";	
	}

Hello,

it seems that theres an error somehwree in my code, I've editied it somewhat so that it kinda suits the arguments that you have included, yet it still fails to print out the statement

else if 
	
		(a==b && a < 1 && a > 32 || b < 1 && b > 32);
	{
		cout << "error in date";
	}

when you pop 345 and 345 it comes back saying nothing, hence the script has done the first part of this code. however it hasnt excuted the 2nd cout statment part.

the 2nd else if works the only difference is that I've told it that if a is not = to b.

else if (a==b && a < 1 && a > 32 || b < 1 && b > 32);
	{
		cout << "error in date";
	}

Don't put a semicolon after the condition of the if statement...

I think your condition should be:

if (a==b && (a<1 || a>32))

since a should be = to b, you do not have to test b for the same condition as a; and, in the way you wrote the if statement, the condition would never become true (a<1 && a>32??)

o dear lol, I'm new to this i think i should go away and re read my statements ... But thanks for your help really greatful

i think i should go away and re read my statements

That's not a bad idea :cheesy:

ok now ive got another little problem

char stringa[12];
char stringb[12];

cout << "your now in prototype";

cin >> stringa;
cin>> stringb;

if ( strcmp ( stringa, stringb) == true)

cout << "equal";

else

cout << "not equal";

ok ignore what the cout means since its not in a prototype, when i enter James and James i get no equal.... Is this due to the fact that they aint pointers?

If the two strings are equal, strcmp returns 0. Usually, true = 1. Make it

if ( strcmp ( stringa, stringb) == 0)
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.