Open
Description
Basic C Programming Assignment
Objective
Develop a set of programs to demonstrate understanding of basic C programming concepts including variables, data types, operators, control structures, and functions.
Assignment Tasks
Task 1: Simple Calculator (15 points)
Create a program that:
- Accepts two numbers and an arithmetic operation (+, -, *, /) from the user
- Performs the selected operation
- Displays the result
- Handles division by zero error
- Uses a switch-case statement for operation selection
Example Interaction:
Enter first number: 10
Enter second number: 5
Select operation (+, -, *, /): *
Result: 50
Task 2: Number Pattern Printer (20 points)
Write a program that:
- Accepts a number from the user (1-10)
- Prints different number patterns using nested loops
- Implement at least 3 different patterns:
- Right-angled triangle of numbers
- Pyramid pattern
- Inverted pyramid pattern
Example Output for input 5:
Pattern 1:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Pattern 2:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Task 3: Array Operations (25 points)
Develop a program that:
- Creates an array of 10 integers
- Implements functions to:
- Input array elements
- Calculate and return the average
- Find the highest and lowest numbers
- Sort the array in ascending order
- Display the array before and after sorting
Task 4: String Manipulation (20 points)
Create a program to:
- Accept a string from the user
- Implement functions to:
- Count the number of characters
- Convert the string to uppercase
- Check if the string is a palindrome
- Remove all spaces from the string
Task 5: Simple Electricity Bill Calculator (20 points)
Design a program that:
- Accepts unit consumption
- Calculates electricity bill based on the following slab rates:
- 0-100 units: ₹0 per unit
- 101-200 units: ₹5 per unit
- 201-300 units: ₹7 per unit
- 301+ units: ₹10 per unit
- Apply additional surcharges:
- 10% additional charge for units above 300
- Display a detailed bill with:
- Total units consumed
- Rate per unit
- Total bill amount
- Surcharge (if applicable)
Evaluation Criteria
- Correct implementation of requirements
- Code readability
- Proper use of functions
- Error handling
- Code efficiency
- Commenting and documentation
Submission Guidelines
- Submit individual .c files for each task
- Include comments explaining your code
- Ensure code compiles without errors
- Handle potential user input errors
Bonus Challenges
- Implement input validation
- Add more complex operations to existing programs
- Optimize your code for performance
- Add additional features not specified in the original requirements
Learning Objectives
- Understand basic C programming syntax
- Practice control structures
- Learn array and string manipulation
- Develop problem-solving skills
- Implement modular programming using functions
Recommended Tools
- Use any C compiler (GCC, Turbo C, Dev-C++)
- Recommended IDEs: Code::Blocks, Visual Studio Code
- Use online compilers for initial testing