only c programming
its all about bingo and we only use 2 functions.. the main and the function for bingo..
here is the problem..
write a function that will accept an integer from 1 to 75(Bingo Numbers). the function should return the appropriate letter corresponding to the numbers entered that:
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"
.. thanks!!!
Functions for c programming...?
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';
}
int main (void)
{
/* whatever has to be done */
return 0;
}
Reply:void bingo(int num)
{
if(num%26gt;=1 %26amp;%26amp; num%26lt;=15)
{
printf("B");
}
if(num%26gt;=16 %26amp;%26amp; num%26lt;=30)
{
printf("I");
}
/* Use conditions for N, G and O */
}
Reply:Function will also return 0 if the number is out of range.
char getBingoLetter(int num)
{
if((num%26gt;=1) %26amp;%26amp; (num%26lt;=75))
{
if(num%26lt;16) return 'B';
if(num%26lt;31) return 'I';
if(num%26lt;46) return 'N';
if(num%26lt;61) return 'G';
return 'O';
}
return '\0';
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment