Assignment Overview
In this assignment, you will write several C programs that demonstrate your understanding of the fundamentals covered in Module 1: program structure, preprocessor directives, data types, variables, and basic I/O operations.
gcc -Wall -Wextra -std=c99. Programs that don't compile receive 0 points.
Program Structure
main() function, return statements, preprocessor directives
Data Types
int, float, double, char, and type modifiers
Input/Output
printf formatting, scanf with format specifiers
The Scenario
TechStart Academy - Day One
Congratulations! You've just joined TechStart Academy as a new programming intern. Your first day starts with a coding orientation where you need to demonstrate basic C programming skills.
"Start simple, think clearly, comment generously. These habits will serve you well throughout your programming career."
Your Task
Create 5 separate C files, each implementing a specific program that demonstrates
fundamental C programming concepts. Your programs should be well-commented, use proper variable
naming conventions, and compile without warnings using gcc -Wall -Wextra -std=c99.
The Dataset
Your programs will be tested with these sample inputs and expected outputs. Ensure your output matches exactly:
Test 1: hello.c (Hello World)
# Expected output (no input required)
$ ./hello
Hello, World!
Test 2: personal_info.c (Personal Info)
# Expected output format (your actual values)
$ ./personal_info
Name: John Doe
Age: 25 years
Height: 5.9 feet
Test 3: calculator.c (Simple Calculator)
# Test Case 1: Basic calculation
$ ./calculator
Enter first number: 10
Enter second number: 3
Sum: 13
Difference: 7
Product: 30
Quotient: 3
# Test Case 2: With negative numbers
$ ./calculator
Enter first number: -5
Enter second number: 3
Sum: -2
Difference: -8
Product: -15
Quotient: -1
Test 4: sizes.c (Data Type Sizes)
# Expected output format
$ ./sizes
Size of char: 1 bytes
Size of short: 2 bytes
Size of int: 4 bytes
Size of long: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Test 5: temperature.c (Temperature Converter)
# Test Case 1: Standard body temperature
$ ./temperature
Enter temperature in Celsius: 37.5
Temperature in Fahrenheit: 99.50
# Test Case 2: Freezing point
$ ./temperature
Enter temperature in Celsius: 0
Temperature in Fahrenheit: 32.00
# Test Case 3: Boiling point
$ ./temperature
Enter temperature in Celsius: 100
Temperature in Fahrenheit: 212.00
Requirements
Complete all of the following programs. Each program should compile without warnings and run correctly.
Hello World Program
Create a program hello.c that:
- Prints "Hello, World!" to the console
- Includes proper header files
- Has correct main() function structure
- Returns 0 on successful execution
// Expected output:
Hello, World!
Personal Information Display
Create a program personal_info.c that:
- Declares variables for name (char array), age (int), and height (float)
- Initializes these with your own information
- Displays them using printf with proper format specifiers
// Expected output format:
Name: John Doe
Age: 25 years
Height: 5.9 feet
Simple Calculator (Input)
Create a program calculator.c that:
- Prompts user to enter two integers
- Uses scanf to read the input
- Calculates and displays sum, difference, product, and quotient
- Handles integer division correctly
// Example interaction:
Enter first number: 10
Enter second number: 3
Sum: 13
Difference: 7
Product: 30
Quotient: 3
Data Type Sizes
Create a program sizes.c that:
- Uses sizeof() operator to display sizes of different data types
- Include: char, int, short, long, float, double
- Display sizes in bytes with proper formatting
// Expected output format:
Size of char: 1 bytes
Size of int: 4 bytes
Size of short: 2 bytes
...
Temperature Converter
Create a program temperature.c that:
- Prompts user to enter temperature in Celsius (float)
- Converts to Fahrenheit using formula: F = (C × 9/5) + 32
- Displays result with 2 decimal places
// Example interaction:
Enter temperature in Celsius: 37.5
Temperature in Fahrenheit: 99.50
Submission
Create a GitHub repository with all your C source files and submit as instructed.
gcc -Wall -Wextra -std=c99. Use make all to build all programs.
Required Files
c-basics-assignment/
├── hello.c
├── personal_info.c
├── calculator.c
├── sizes.c
├── temperature.c
├── Makefile
└── README.md
README.md Must Include:
- Your full name and submission date
- Brief description of each program
- Compilation instructions (e.g.,
gcc hello.c -o hello) - Any challenges faced and how you solved them
Do Include
- All 5 programs completed and working
- Proper code comments
- Consistent indentation and formatting
- Meaningful variable names
Do Not Include
- Compiled executables (.exe, .out files)
- IDE project files
- Code that doesn't compile
- Plagiarized code
Grading Rubric
| Criteria | Points | Description |
|---|---|---|
| Program 1: Hello World | 15 | Correct structure, output, and return value |
| Program 2: Personal Info | 20 | Proper variable declarations and printf formatting |
| Program 3: Calculator | 25 | Correct scanf usage and arithmetic operations |
| Program 4: Data Sizes | 20 | Correct sizeof usage and output formatting |
| Program 5: Temperature | 20 | Correct formula, float handling, and decimal formatting |
| Total | 100 |
Ready to Submit?
Make sure you have completed all requirements and reviewed the grading rubric above.
Submit Your AssignmentWhat You Will Practice
Program Structure
Writing well-formed main() functions with proper headers and preprocessor directives
Output Formatting
Using printf with format specifiers and escape sequences for formatted output
User Input
Reading input safely with scanf and correct format specifiers for different data types
Data Types
Understanding variable sizes with sizeof operator and choosing appropriate types
Pro Tips
Compile Early & Often
- Test after every few lines of code
- Catch errors early when easier to fix
- Use
gcc -Wall -Wextrafor warnings - Read error messages carefully
Comment Your Code
- Explain what each section does
- Helps graders understand your thinking
- Useful for your own review later
- Document any assumptions made
Test Edge Cases
- Calculator: zero, negative, large values
- Temperature: 0°C, 100°C, -40°C
- Compare output format exactly
- Test on different compilers if possible
Common Mistakes
- Forgetting
#include <stdio.h> - Missing
return 0;in main() - Wrong format specifier for data type
- Including compiled executables in repo