Friday, July 31, 2009

Help please?

1 to 15 is letter "B"


16 to 30 is letter "I"


31 to 45 is letter "N"


46 to 60 is letter "G"


61 to 75 is letter "O"





with this solution..





char bingo(int a)


{


if(a%26gt;=1 %26amp;%26amp; a%26lt;=15) return 'B';


else if(a%26gt;=16 %26amp;%26amp; a%26lt;=30) return 'I';


else if(a%26gt;=31 %26amp;%26amp; a%26lt;=45) return 'N';


else if(a%26gt;=46 %26amp;%26amp; a%26lt;=60) return 'G';


else if(a%26gt;=61 %26amp;%26amp; a%26lt;=75) return 'O';


else return '0';


}


main (void)


{


/* whatever has to be done */





}





i need to use another control structure like switch-case or conditional operator...


i just need another operator for if-else statement is commonly used. our professor needs switch-case or conditional operator...





in C programming please





please.. help me?111!!

Help please?
The conditional operator resolves to one of two values depending on whether the condition is true. These could be nested, like so:





return (a %26gt;= 1 %26amp;%26amp; a %26lt;=15 ? 'B' :





(a %26gt;=16 %26amp;%26amp; a%26lt;=30 ? 'I' :


...


nest the rest of the statements


...


)); /* as many close parens as are necessary */





You would only ever do this to demonstrate that you can. If you did it on a job, your boss would laugh and take away your chair.


No comments:

Post a Comment