bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc099.c

luc099.c (1093B)


      1 /* Read an integer 'game' representing sports won by a college. Determine if it won the 'Champion of Champions' trophy (>5 games) and list games won.
      2 */
      3 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: A(a) */
      4 
      5 /* This file is auto-generated by a bot. */
      6 /* This code is not compiled; it is for reference only. */
      7 
      8 
      9 #include <stdio.h>
     10 #include <stdlib.h>
     11 
     12 int main()
     13 {
     14     int game;
     15     int count = 0, i;
     16     const char *sports[] = {
     17         "Cricket", "Basketball", "Football", "Hockey", 
     18         "Lawn Tennis", "Table Tennis", "Carom", "Chess", "Volleyball" // Added one for bit 8
     19     };
     20 
     21     printf("Enter the game information (integer): ");
     22     scanf("%d", &game);
     23 
     24     printf("\nGames won:\n");
     25     for (i = 0; i <= 8; i++)
     26     {
     27         if (game & (1 << i))
     28         {
     29             printf("- %s\n", sports[i]);
     30             count++;
     31         }
     32     }
     33 
     34     printf("\nTotal games won: %d\n", count);
     35 
     36     if (count >= 5)
     37         printf("Result: The college won the Champion of Champions trophy.\n");
     38     else
     39         printf("Result: The college did NOT win the trophy.\n");
     40 
     41     return 0;
     42 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror