Multi-session hands-on C programming practice with interactive tools
Grade XI • Computer Science ⏱️ Multi-SessionBrief Intro — Programming in C Lab
Reading about code is helpful, but the only way to truly master programming is by rolling up your sleeves and writing it yourself. This multi-session lab provides a structured path for you to practice everything from basic input/output to complex logic and data storage.
In this activity, you'll build your skills through hands-on tasks that cover C fundamentals, control structures, and array manipulation, giving you the practical experience needed to create your own applications.
Every C program follows a standard structure, using data types and basic input/output functions to communicate with the user.
A C program has a standard layout including preprocessor directives, the main() function, and variable declarations.
#include <stdio.h>
int main(void) {
printf("Hello, World\n");
return 0;
}
| Data Type | Description | Format Specifier | Size (Typical) |
|---|---|---|---|
| int | Integer (whole numbers) | %d or %i | 4 bytes |
| float | Single-precision floating point | %f | 4 bytes |
| double | Double-precision floating point | %lf | 8 bytes |
| char | Single character | %c | 1 byte |
Write a program to display an integer, a float, and a double value stored in different variables. Then, modify it to take these values from the user using scanf().
Declare int a; float b; double c;. Use scanf("%d %f %lf", &a, &b, &c); and then print them back.
Take a character from the user and print both the character and its corresponding ASCII value.
Use %c to read/print the character and %d to print its integer (ASCII) value.
Write a program to check the size of different variables (short, long, long long, long double) using the sizeof() operator.
Use printf("Size: %d", sizeof(variable_name));
Implement the following calculations based on user input:
Operators are the tools for mathematical, relational, and logical manipulation of data.
Select an operator and enter values to see how C evaluates the expression.
Take two integers from the user and perform all arithmetic operations (+, -, *, /, %).
Demonstrate the use of ++ and -- operators in both prefix and postfix forms.
Write two programs to swap two numbers:
a = a + b; b = a - b; a = a - b;
Practice logical decision making:
Control structures give your program the intelligence to make choices and the power to repeat tasks efficiently.
Write two programs using switch case:
Write a program to find if an entered integer is odd or even using if-else.
Practice different loop ranges and accumulations:
Use a for loop to:
pow().Write programs to print the following shapes using nested loops:
Master these classic algorithms to sharpen your logical thinking and mathematical programming skills.
Implement logic to process the digits of a number:
Solve these cornerstone programming problems:
Arrays allow you to store and manage collections of data efficiently using indexed memory locations.
Practice common array tasks:
n values and display them in reverse order.Work with matrices:
Strings are character arrays with special handling in C, supported by a rich set of library functions.
Use string.h functions to:
strlen().strcmp().strcpy().Re-implement library logic without using string.h:
while loop.Iterate until you encounter the null character '\0'.
Write a program that uses math.h to demonstrate sqrt(), pow(), and abs().
Ready to test your knowledge?
Take the Assessment →