


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Question 1 [ 35 marks] You have been tasked with reprogramming a microcontroller-based temperature monitoring system. This system is designed to monitor and control temperatures in an industrial processing unit. The system currently follows the operational rules below:
Provide a screenshot of your full code and answers in a single PDF submission and attach the .c file in your practical 3 submission. BEGIN // Step 1: Define Constants for BMI Ranges using Preprocessor DEFINE UNDERWEIGHT 18. DEFINE NORMAL_WEIGHT 24. DEFINE OVERWEIGHT 29. // Step 2: Get User Input PRINT "Enter weight (kg):" READ weight PRINT "Enter height (m):" READ height // Step 3: Validate Input (Height must be > 0) IF height == 0 THEN PRINT "Error: Height cannot be zero." EXIT PROGRAM END IF // Step 4: Calculate BMI BMI = weight / (height * height) // Step 5: Classify BMI using Conditional Statements IF BMI < UNDERWEIGHT THEN category = "Underweight" flag = 1 // 0001 ELSE IF BMI >= UNDERWEIGHT AND BMI <= NORMAL_WEIGHT THEN category = "Normal Weight" flag = 2 // 0010 ELSE IF BMI > NORMAL_WEIGHT AND BMI <= OVERWEIGHT THEN category = "Overweight" flag = 4 // 0100 ELSE category = "Obese" flag = 8 // 1000 END IF // Step 6: Use Bitwise Operations to Identify Health Warnings PRINT "Your BMI is:", BMI PRINT "Category:", category IF flag & 1 THEN PRINT "Warning: You are underweight. Increase calorie intake." END IF IF flag & 4 THEN PRINT "Warning: Risk of obesity-related diseases. Exercise regularly." END IF IF flag & 8 THEN PRINT "Warning: High risk! Consult a doctor immediately." END IF END