Hi,
This brings the question of when to use "switch" and when to use "if-elseif"
combo.
When the number of conditions you need to check are less, its easy to use
if-elseif-else
to handle it.
In the case you had mentioned, you can check for only one outcome of the
"switch" statement.
Eg. switch(a>b) -> either would return a 0 or 1 as answer.
But we have 2 more combinations possible.
#1. is a = b?
#2. is a < b
Both of these are possible if the "switch" returns a '0'.
So its better to use if-elseif-else
if(a <b)
{
/* a is less than b*/
}
else if(a>b)
{
/* a is greater than b*/
}
else
{
/* a and b are equal */
}
"switch" statements can be used when the iterations are more. Eg.
switch(day)
{
case MONDAY:
printf("Monday");
break;
case TUESDAY:
printf("Tuesday");
break;
.
.
.
.
default:
printf(" Invalid Day");
break;
}
ºéº£À¥ <[EMAIL PROTECTED]> wrote:
i'm a newer in C,i have something unknown.
switch ( ? ) { ---------------if the case can be a>b,what should be put in the
blanket?
case a>b : -----------does the case be "a>b"
a nested programming ------can i put a nested programming here
break;
}
waiting for your reply
thanks
__________________________________________________________
ÑÅ»¢ÓÊÏ䣬ÖÕÉú»ï°é£¡
http://mail.yahoo.com.cn/
[Non-text portions of this message have been removed]
---------------------------------
For ideas on reducing your carbon footprint visit Yahoo! For Good this month.
[Non-text portions of this message have been removed]