luc099.c (1284B)
1 /* 2 * Author : Amit Dutta <amitdutta4255@gmail.com> 3 * Date : 08 Feb 2026 4 * Repo : https://github.com/notamitgamer/bsc 5 * License : MIT License (See the LICENSE file for details) 6 */ 7 8 /* 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. 9 */ 10 /* Let Us C, Chap- 21 (Operations on Bits), Qn No.: A(a) */ 11 12 /* This file is auto-generated by a bot. */ 13 /* This code is not compiled; it is for reference only. */ 14 15 16 #include <stdio.h> 17 #include <stdlib.h> 18 19 int main() 20 { 21 int game; 22 int count = 0, i; 23 const char *sports[] = { 24 "Cricket", "Basketball", "Football", "Hockey", 25 "Lawn Tennis", "Table Tennis", "Carom", "Chess", "Volleyball" // Added one for bit 8 26 }; 27 28 printf("Enter the game information (integer): "); 29 scanf("%d", &game); 30 31 printf("\nGames won:\n"); 32 for (i = 0; i <= 8; i++) 33 { 34 if (game & (1 << i)) 35 { 36 printf("- %s\n", sports[i]); 37 count++; 38 } 39 } 40 41 printf("\nTotal games won: %d\n", count); 42 43 if (count >= 5) 44 printf("Result: The college won the Champion of Champions trophy.\n"); 45 else 46 printf("Result: The college did NOT win the trophy.\n"); 47 48 return 0; 49 }