Back to Home
Free Programming Course

C ProgrammingFoundations, Syntax & Systems Programming

A structured C course covering syntax, variables, operators, control flow, arrays, functions, pointers, structures, preprocessor, and file handling.

7 hrs self-paced
Beginner → Intermediate
Systems Ready
6
Modules
168
Topics
6
Quizzes
30
Practice Drills
7h
Self-paced

Your Learning Progress

Modules complete
0 / 6
Drills done
0 / 30
Remaining items
36
Completion
0%

Module 1 – Introduction to C, Syntax, Variables, and Output

1.1 What is C?

Definition C is a general-purpose, procedural programming language used for system programming, embedded systems, operating systems, and performance-critical applications. Why C matters: It is fast and efficient. It gives direct control over memory. It is the foundation for many modern languages. It is widely used in embedded and low-level programming.

1.2 First C Program

Code

c
1#include <stdio.h>
2
3int main(void) {
4 printf("Hello World!\n");
5 return 0;
6}

Explanation #include <stdio.h> includes the standard input/output library. int main(void) is the entry point of the program. printf() prints output to the screen. return 0; indicates successful program execution. Compile and Run

bash
1gcc hello.c -o hello
2./hello

Output

c
1Hello World!

1.3 Structure of a C Program

A typical C program has these parts: Preprocessor directives Main function Variable declarations Statements Return statement Example

c
1#include <stdio.h>
2
3int main(void) {
4 int num = 5;
5 printf("%d\n", num);
6 return 0;
7}

1.4 Variables

Definition A variable is a named storage location used to store data that may change during program execution. Example

c
1int myNum = 15;
2
3int myNum2;
4myNum2 = 15;
5
6int myNum3 = 15;
7myNum3 = 10;

Explanation myNum is initialized immediately. myNum2 is declared first and assigned later. myNum3 is updated after initial assignment.

1.5 Constants

Definition A constant is a value that cannot be changed after initialization. Example

c
1const int minutesPerHour = 60;
2const float PI = 3.14;
3const int BIRTHYEAR = 1980;

Best Practice Use uppercase names for constants to make them easy to identify.

1.6 Comments

Definition Comments are notes in the source code that are ignored by the compiler. Single-line comment

c
1// this is a comment
2printf("Hello World!"); // comment at the end of a line

Multi-line comment

c
1/* Multi-line comment,
2 print Hello World!
3 to the screen, it's awesome */

1.7 Printing Text

Example

c
1printf("I am learning C.");

Print variables

c
1int testInteger = 5;
2printf("Number = %d", testInteger);

Common format specifiers %d for integers %f for float %c for character %s for string %lf for double

1.8 Data Types

Definition Data types tell the compiler what kind of data a variable can store and how much memory it needs. Basic types char short int long float double void Example

c
1int myNum = 5;
2float myFloatNum = 5.99;
3char myLetter = 'D';
4double myDouble = 3.2325467;
5
6printf("%d\n", myNum);
7printf("%f\n", myFloatNum);
8printf("%c\n", myLetter);
9printf("%lf\n", myDouble);

1.9 Number Systems

C can store numbers in different bases. Binary

c
1short a = 0b1010110;

Octal

c
1int b = 02713;

Hexadecimal

c
1long c = 0X1DAB83;

Print in different formats

c
1printf("a=%ho, b=%o, c=%lo\n", a, b, c);
2printf("a=%hd, b=%d, c=%ld\n", a, b, c);
3printf("a=%hx, b=%x, c=%lx\n", a, b, c);
4printf("a=%hX, b=%X, c=%lX\n", a, b, c);

1.10 Formatting Output

Example

c
1int a1 = 20, a2 = 345, a3 = 700;
2int b1 = 56720, b2 = 9999, b3 = 20098;
3
4printf("%-9d %-9d %-9d\n", a1, a2, a3);
5printf("%-9d %-9d %-9d\n", b1, b2, b3);

Explanation %d prints decimal integers. 9 means minimum width 9.

  • means left alignment.

1.11 Best Practices

Use meaningful variable names. Use constants for fixed values. Format code properly. Keep comments short and useful. Prefer clear, readable output formatting.

1.12 Practice Exercises

Write a program to print your name. Write a program to store and print your age. Declare three variables and print their sum. Print a float and a double using correct format specifiers. Try printing a number in decimal, octal, and hex form.

Module 1 Recap In this module, you learned: What C is How a C program is structured How to compile and run a program Variables, constants, comments, and output Data types and format specifiers Different number systems Absolutely — here is Module 2: Operators, Conditions, and Loops in the same detailed coursebook style, with expanded explanations, syntax, examples, and practice ideas.

Practice Drill

Module 1 Quiz

1. Which statement best describes Module 1 – Introduction to C, Syntax, Variables, and Output?
2. What is the recommended way to reinforce this module?
3. Why does clean structure matter in code?

Practice Drill Bank

Every practice drill from the course, organised by module. Rehearse these until they feel automatic.

Final Revision Checklist

Tick items as you master them — progress saves automatically.

Module 1Module 1 – Introduction to C, Syntax, Variables, and Output

Module 2Module 2: Operators, Conditions, and Loops

Module 3Module 3: Arrays, Strings, and Enumerations

Module 4Module 4: Functions, Scope, and Recursion

Module 5Module 5: Pointers, Memory Address, and Structures

Module 6Module 6: Preprocessor and File Handling

Congratulations!

You've finished the CodeStudio C Programming course. Revise, drill, and keep building.

Back to Home