0
0
Cprogramming~15 mins

Basic data types - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic Data Types in C
📖 Scenario: You are creating a simple program to store and display information about a product in a store.
🎯 Goal: Build a C program that declares variables of different basic data types, assigns values, and prints them.
📋 What You'll Learn
Declare variables of type int, float, char, and char[]
Assign specific values to each variable
Print the values using printf
💡 Why This Matters
🌍 Real World
Basic data types are the foundation for storing and managing data in any C program, such as inventory systems or calculators.
💼 Career
Understanding data types is essential for software development, embedded systems programming, and any technical job involving C language.
Progress0 / 4 steps
1
Declare variables with initial values
Declare an int variable called product_id and set it to 101. Declare a float variable called price and set it to 29.99.
C
Need a hint?

Use int for whole numbers and float for decimal numbers.

2
Add character variables
Declare a char variable called category and set it to 'A'. Declare a char array called name with the value "Pen".
C
Need a hint?

Use single quotes for char and double quotes for char arrays (strings).

3
Print all variables
Use printf to print product_id, price, category, and name each on a new line with labels.
C
Need a hint?

Use %d for int, %.2f for float with 2 decimals, %c for char, and %s for strings.

4
Run and check output
Run the program and ensure the output matches exactly: Product ID: 101 Price: 29.99 Category: A Name: Pen
C
Need a hint?

Make sure your output matches exactly, including spaces and new lines.