/* * Author : Amit Dutta * Date : 08 Feb 2026 * Repo : https://github.com/notamitgamer/bsc * License : MIT License (See the LICENSE file for details) */ /* Automobile engine parts (Serial AA0-FF9, Year, Material, Qty). Retrieve parts between serial numbers BB1 and CC6. */ /* Let Us C, Chap- 17 (Structures), Qn No.: B(c) */ /* This file is auto-generated by a bot. */ /* This code is not compiled; it is for reference only. */ #include #include #include struct part { char serial[4]; // 3 chars + null terminator int mfg_year; char material[20]; int quantity; }; void retrieve_parts(struct part *p, int n); int main() { struct part inventory[] = { {"AA0", 2020, "Steel", 50}, {"BB2", 2021, "Aluminum", 20}, {"BB5", 2022, "Carbon", 10}, {"CC1", 2021, "Steel", 100}, {"CC7", 2023, "Titanium", 5}, {"FF9", 2024, "Iron", 60} }; int n = 6; printf("--- Parts with Serial Numbers between BB1 and CC6 ---\n"); retrieve_parts(inventory, n); return 0; } void retrieve_parts(struct part *p, int n) { int i; // We compare strings lexicographically char start[] = "BB1"; char end[] = "CC6"; for (i = 0; i < n; i++) { if (strcmp(p[i].serial, start) >= 0 && strcmp(p[i].serial, end) <= 0) { printf("Serial: %s | Year: %d | Mat: %s | Qty: %d\n", p[i].serial, p[i].mfg_year, p[i].material, p[i].quantity); } } }