[prog] Re: more C++
Conor Daly
conor.daly at oceanfree.net
Sat Dec 13 23:57:07 EST 2003
On Sat, Dec 13, 2003 at 05:46:20PM -0500 or so it is rumoured hereabouts,
wolf thought:
> Well this works but I got the answer via trial and error : )
> Could anyone help explain very fundamentally why it works when I
> comment out the one line? : )
>
> else //(integer1 % 2 !=0)
> std::cout << "Your number is odd." << std::endl;
Remenber where Dominick said:
"if" "(" condition ")" statement1 "else" statement2
an if-else block can look like any of:
if(...)
statement;
else
statement;
or
if(...) statement; else statement;
or
if(...) {
statement1;
statement2;
}
else {
statement3;
statement4;
}
or
if(...) {
statement1;
statement2;
}
else
statement3;
Your:
> else //(integer1 % 2 !=0)
> std::cout << "Your number is odd." << std::endl;
is the equivalent of:
else
std::cout << ......;
so it has become a proper else block. The 'if' section (the "is integer
even" test) was already properly constructed.
Conor
--
Conor Daly <conor.daly at oceanfree.net>
Domestic Sysadmin :-)
---------------------
Faenor.cod.ie
10:54pm up 51 days, 16:02, 0 users, load average: 0.10, 0.13, 0.11
Hobbiton.cod.ie
10:50pm up 51 days, 15:54, 1 user, load average: 0.01, 0.01, 0.00
More information about the Programming
mailing list