Assignment 1-A

Hello C World

Build your first C programs that demonstrate understanding of program structure, data types, variables, and basic input/output using printf and scanf.

2-3 hours
Beginner
100 Points
Submit Assignment
What You Will Practice
  • Write properly structured C programs
  • Use printf for formatted output
  • Use scanf for user input
  • Declare and use variables
  • Work with different data types
Contents
Ready to Submit?

Already completed your programs? Submit now for grading!

01

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.

Skills Applied: This assignment tests your understanding of C History & Setup (1.1) and Program Structure & Basic Syntax (1.2) from Module 1.
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

02

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."

Senior Developer

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.

03

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
Note: Your output format should match these examples exactly. Pay attention to spacing, punctuation, and decimal places.
04

Requirements

Complete all of the following programs. Each program should compile without warnings and run correctly.

1
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!
2
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
3
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
4
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
...
5
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
05

Submission

Create a GitHub repository with all your C source files and submit as instructed.

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
06

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 Assignment
07

What 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

08

Pro Tips

Compile Early & Often
  • Test after every few lines of code
  • Catch errors early when easier to fix
  • Use gcc -Wall -Wextra for 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
09

Pre-Submission Checklist

Code Requirements
Repository Requirements