0% found this document useful (0 votes)
4 views5 pages

Structured Programming Assignment Sets

The document outlines a structured programming language assignment focused on C, divided into seven sets covering various topics such as conditional control structures, logical operator debugging, loop control, mathematical logic, variable initialization errors, multi-tiered conditionals, and sentinel-controlled processing. Each set contains multiple topics with specific programming tasks and explanations required for each scenario. The assignments are designed to enhance understanding of core programming concepts and logical reasoning in coding.

Uploaded by

sensashonal.dev
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Structured Programming Assignment Sets

The document outlines a structured programming language assignment focused on C, divided into seven sets covering various topics such as conditional control structures, logical operator debugging, loop control, mathematical logic, variable initialization errors, multi-tiered conditionals, and sentinel-controlled processing. Each set contains multiple topics with specific programming tasks and explanations required for each scenario. The assignments are designed to enhance understanding of core programming concepts and logical reasoning in coding.

Uploaded by

sensashonal.dev
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

THEORY ASSIGNMENT - COMPANION QUESTION

SETS
Subject: Structured Programming Language (C) | Extended 7-Set Matrix

Set 1: Basic Conditional Control Structures


Difficulty: Easy | Core Concept: Multi-way selection using exact choices (switch-case / if-else)

1. Topic 1 (Smart Home): A smart thermostat accepts 1 for Heating mode and 2 for Cooling mode. Write
a C program to print the status: "Heating Activated" for 1 and "Cooling Activated" for 2. If the input is
neither, print "Invalid Mode."

2. Topic 2 (E-Commerce): An online store offers two shipping options: 1 for Standard Shipping ($5.00) and
2 for Express Shipping ($15.00). Write a C program that takes the choice as input and prints the shipping
cost. If the user enters anything else, display "Invalid Shipping Choice."

3. Topic 3 (Fitness App): A fitness tracker allows users to select a workout goal: 1 for Cardio and 2 for
Strength Training. Write a C program that outputs "Cardio mode selected: Target 30 mins" or "Strength
mode selected: Target 45 mins" based on the input. Print "Goal not recognized" for other values.

4. Topic 4 (Automated Parking): A parking garage machine asks the user to enter 1 for a Motorbike or 2
for a Car. Write a C program to display the hourly rates: $2.00 for motorbikes and $5.00 for cars. For any
other input, print "Vehicle Type Unknown."

5. Topic 5 (Digital Menu): A cafe's digital kiosk asks customers to press 1 for Coffee and 2 for Tea. Write
a C program to display the price: $3.50 for coffee and $2.75 for tea. If the input is invalid, display "Item not
on menu."

Set 2: Logical Operator Debugging


Difficulty: Easy-Medium | Core Concept: Identifying short-circuit flaws & logical range overlaps (|| vs &&)

1. Topic 1 (Banking): A bank program uses if (balance >= 100 || balance <= 500) to check if a
user qualifies for a standard tier account without extra fees. Explain why this logic evaluates to true for
every possible balance value, and rewrite it using the correct operator.

2. Topic 2 (Gaming): A video game attempts to restrict an area to mid-level players using
if (level >= 10 || level <= 50) . Explain why players of all levels (even level 1 or level 100) are
accidentally allowed in, and provide the corrected code.

3. Topic 3 (Weather Alerts): A weather application triggers a safety alert using


if (temperature >= 35 || temperature <= 0) to find moderate, safe outdoor conditions. Explain
why this logic mistakenly flags every temperature as "safe", and correct the statement.

Structured Programming Language | Extended Assignment Sets Page 1 of 5


4. Topic 4 (Employee Benefits): An HR system checks if an employee is eligible for a bonus based on years
of service using if (years >= 2 || years <= 10) . Explain the logical flaw that makes every
employee eligible, and rewrite it correctly.

5. Topic 5 (Academic Grading): A grading tool uses if (score >= 40 || score <= 100) to determine
if a student passed a test. Explain why this condition fails to isolate the proper passing range and accepts
failing scores, then rewrite it with the proper operator.

Set 3: Loop Control & Keyword Side-Effects


Difficulty: Medium | Core Concept: Structural analysis of loop bypass keywords placed before updates

1. Topic 1 (Aviation Fuel): A drone tracking system runs a loop while fuel > 0 . Inside the loop, it
consumes fuel using fuel = fuel - 5; . A student adds a continue; statement at the very top of the
loop body. Explain why this creates an infinite loop and how it affects execution.

2. Topic 2 (Event Management): A ticketing system counts down available seats using a while loop
condition seats > 0 . Inside, it decrements seats-- . If a continue; statement is inserted before the
decrement operation, explain what happens to the system's execution.

3. Topic 3 (Cybersecurity): A security system limits login attempts using a loop while attempts_left >
0 . A programmer inadvertently places a continue; statement at the top of the loop before
attempts_left-- is executed during a failed login. Explain the security vulnerability this introduces.

4. Topic 4 (Digital Downloads): A file manager processes a download queue using while
(remaining_files > 0) . The file count is meant to reduce by 1 after each download. If a continue;
keyword is placed at the beginning of the loop, explain why the download progress freezes.

5. Topic 5 (Manufacturing Plant): A factory robot processes items in a batch while items_left > 0 . Due
to a logic modification, a continue; statement is added at the first line of the loop body, skipping the
items_left = items_left - 1; line. Explain the structural failure this causes.

Set 4: Mathematical Logic in Conditionals


Difficulty: Medium | Core Concept: Checking algorithmic properties of inputs using precise conditional evaluation

1. Topic 1 (Digital Security): Construct a C program that takes a single digit (0-9) as an input pin element.
Use an if-else block to print "Access Granted" if the digit is an even number greater than 0, and "Access
Denied" otherwise.

2. Topic 2 (Inventory Systems): A warehouse slots inventory based on single digits (0-9). Write a C
program where an if-else structure prints "Perishable Section" if the digit is a perfect square (e.g., 1, 4, 9),
and "Dry Storage Section" for all other digits.

3. Topic 3 (Game Mechanics): In a turn-based board game, a player rolls a custom 0-9 single-digit spinner.
Write a C program using an if-else block to check if the spun number is an odd number. Print "Bonus Move
Awarded" if it is odd, and "Regular Turn" otherwise.

Structured Programming Language | Extended Assignment Sets Page 2 of 5


4. Topic 4 (Telecommunications): A phone routing system takes a single-digit extension identifier (0-9).
Write a C program that checks if the input digit is a multiple of 3 (excluding 0). Print "Priority Line" if true,
and "Standard Line" otherwise.

5. Topic 5 (Quality Control): A manufacturing sensor outputs an error status code as a single digit (0-9).
Write a C program that uses an if-else block to check if the code is greater than 5. If it is, print "Critical
Alert"; otherwise, print "System Nominal."

Set 5: Variable Initialization & Multiplicative Identity Errors


Difficulty: Medium | Core Concept: Explaining logic bugs related to initializing product/running-multiplier loops to zero

1. Topic 1 (Finance): A program designed to calculate compound interest over a series of intervals initializes
a running multiplier variable double growth_factor = 0.0; . Explain why the calculated final wealth will
always return 0 regardless of inputs, and provide the corrected initialization.

2. Topic 2 (Physics Simulation): A software module calculates the total combinations of subatomic states
by multiplying the states together. The developer initializes int total_combinations = 0; before
running a loop of calculations. Explain why the result remains zero, and state the fix.

3. Topic 3 (E-Commerce Sales): A system calculates the bulk geometric discount scale of products by
multiplying discount coefficients together. If it initializes float final_scale = 0; , explain why the
discount calculation fails completely and how to fix it.

4. Topic 4 (Geometry App): A program calculates the product of the lengths of several sides of a polygon to
determine a spatial scalar value. The variable is initialized as int side_product = 0; . Explain the
mathematical error this causes during successive loop multiplications and provide the remedy.

5. Topic 5 (Data Analytics): An algorithm calculates the geometric mean of an array of metrics and begins
by initializing a running product variable double product = 0; . Explain why this initialization ruins the
data processing loop and write the corrected code snippet.

Set 6: Multi-Tiered Conditionals & Surcharges


Difficulty: Medium-Hard | Core Concept: Computing step-wise math logic via flat baseline fees plus over-threshold penalties

1. Topic 1 (Utility Bills): A water utility company charges a flat fee of $15 per month for usage up to 20 units.
For usage exceeding 20 units, an additional penalty rate of $2.50 per unit is charged for the extra units
consumed. Write a C program that takes total water units consumed as input and calculates the final bill.

2. Topic 2 (Vehicle Rental): A car rental service charges a flat $40 per day fee. If the customer drives the
car more than 100 miles during the rental period, an additional flat surcharge of $35 is added to the bill as
a high-mileage penalty. Write a C program that takes the number of days and total miles driven as inputs
and calculates the total rental fee.

Structured Programming Language | Extended Assignment Sets Page 3 of 5


3. Topic 3 (Taxation Software): A local municipal authority levies a corporate property tax of $500 flat per
year. If the property area exceeds 5,000 square feet, an additional expansion tax of $0.10 per square foot
is levied on the area exceeding 5,000. Write a C program to accept the total square footage and output the
total tax due.

4. Topic 4 (Shipping & Logistics): A courier service charges a flat $10 fee for packages up to 5 kg. For
packages heavier than 5 kg, an extra heavy-duty handling fee of $3 per kg is added for every kilogram over
the 5 kg limit. Write a C program that takes package weight as an input and outputs the total shipping cost.

5. Topic 5 (Cloud Computing): A cloud platform charges a flat $25 service fee per month for database
hosting. If data egress exceeds 50 GB, an additional fee of $0.50 per GB is charged for each gigabyte over
the limit. Write a C program that takes total data egress in GB as input and computes the monthly
statement cost.

Set 7: Sentinel-Controlled Nested Multi-User Processing


Difficulty: Hard | Core Concept: Inner loops scanning variable numbers of records until a sentinel breaks, wrapped inside
an outer user loop

1. Topic 1 (Warehouse Inventory Auditing): A logistics application is upgrading its inventory auditing
system to process T number of cargo trucks. For each truck, the system first registers its maximum
payload capacity (in kg). Then, it sequentially scans item weights (in kg) being loaded for multiple planned
drops. The scanning process for a truck stops when a sentinel value of -1 is entered. The system applies
a structural packaging tare weight of 5 kg per item loaded. Construct a complete C program to process the
trucks.

Output Requirements:
◦ Print TRUCK SAFE if the truck's maximum payload capacity covers the accumulated total weight of
the items (including tare weights).
◦ Print OVERLOADED if there is a weight violation.

2. Topic 2 (Gym Member Calorie Tracker): A fitness management system tracks daily energy metrics by
processing T number of athletes. For each athlete, the system registers their daily target calorie
expenditure. Then, it sequentially scans the calories burned across multiple individual exercise sessions
throughout the day. The input process for an athlete stops when a sentinel value of -1 is entered. Due to
metabolic inefficiencies, the actual net calorie burn is calculated as 90% of the recorded calories per
session. Construct a complete C program to process the athletes.

Output Requirements:
◦ Print GOAL ACHIEVED if the athlete's total net calories burned meets or exceeds their target.
◦ Print TARGET INCOMPLETE if they fall short.

Structured Programming Language | Extended Assignment Sets Page 4 of 5


3. Topic 3 (Event Ticketing Console): An entertainment arena is processing group bookings for an event
series across T corporate clients. For each client, the program registers their allocated budget. Then, it
sequentially reads individual ticket price quotes for the various VIP sub-events they want to add to their
package. The scanning stops when a sentinel value of -1 is entered. There is a mandatory processing
fee of $10 added to every individual ticket requested. Construct a complete C program to process the
clients.

Output Requirements:
◦ Print BOOKING SUCCESSFUL if the client's corporate budget covers the total calculated ticket fees.
◦ Print BUDGET EXCEEDED if the total cost is too high.

4. Topic 4 (Agribusiness Supply Control): A grain silo system manages distributions across T regional
farms. For each farm, the system registers the total available empty storage space (in bushels). It then
sequentially reads incoming quantities from various harvest trucks arriving from that farm's fields. The input
sequence for a farm terminates when a sentinel value of -1 is entered. Because of settling and moisture
variables, each incoming truckload expands effectively by 1.05 times its raw volume in storage. Construct a
complete C program to process the farms.

Output Requirements:
◦ Print SILO FIT CONFIRMED if the farm's empty storage space can contain the total accumulated
harvest volume.
◦ Print OVERFLOW RISK if the grain volume exceeds capacity.

5. Topic 5 (Freelance Project Time Sheet): An agency dashboard tracks billing for T independent
freelancers. For each freelancer, the system registers their pre-approved maximum allowable monthly
billable hours. Then, the system sequentially inputs the hours logged across multiple separate project
tasks. The input loop for a freelancer ends when a sentinel value of -1 is entered. The agency applies an
administrative overhead adjustment that scales the recorded task hours by a factor of 1.15 to account for
project communication. Construct a complete C program to process the freelancers.

Output Requirements:
◦ Print HOURS APPROVED if the freelancer's calculated total adjusted hours stay within their maximum
allowed limit.
◦ Print LIMIT VIOLATION if they exceed the maximum pre-approved allowance.

Structured Programming Language | Extended Assignment Sets Page 5 of 5

You might also like