0% found this document useful (0 votes)
11 views11 pages

C Programming Course: Beginner to Advanced

Uploaded by

itssky747
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

C Programming Course: Beginner to Advanced

Uploaded by

itssky747
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C Programming Language

Complete Beginner to Advanced Course

Prepared by: Shivendra kumar Yadav


Date: 17-09-2025

Features of this Book:

• Beginner-friendly explanations

• Code examples with outputs

• Practice exercises

• Mini projects (Calculator, Games, Management Systems)

• Step-by-step learning path

Table of Contents

1. Introduction to C

2. Structure of a C Program

3. Data Types and Variables

4. Control Statements

5. Loops in C

6. Functions

7. Arrays and Strings

8. Pointers

9. Structures

10. File Handling

11. Practice Exercises

12. Mini Projects in C

• Simple Calculator

• Number Guessing Game

• Student Management System

• Tic-Tac-Toe (2 Players)
C Programming Course

Chapter 1: Introduction to C

C is one of the oldest and most powerful programming languages.

• It is fast, portable, and forms the foundation of many modern languages like C++, Java, and
Python.

• Learning C helps in understanding how computers manage memory and execute


instructions.

Chapter 2: Structure of a C Program

#include <stdio.h>

int main() {

printf("Hello, World!\n");

return 0;

Explanation

• #include <stdio.h> → Library for input/output.

• int main() → Entry point of execution.

• printf() → Prints output.

• return 0; → Ends program successfully.

Chapter 3: Data Types and Variables

#include <stdio.h>

int main() {

int age = 20;

float pi = 3.14;

char grade = 'A';

printf("Age: %d\n", age);


printf("Pi: %.2f\n", pi);

printf("Grade: %c\n", grade);

return 0;

Chapter 4: Control Statements

#include <stdio.h>

int main() {

int num = -3;

if(num > 0) {

printf("Positive\n");

} else if(num == 0) {

printf("Zero\n");

} else {

printf("Negative\n");

return 0;

Chapter 5: Loops in C

For loop

for(int i=1; i<=5; i++) {

printf("%d\n", i);

While loop

int i = 1;

while(i <= 5) {

printf("%d\n", i);
i++;

Do-While loop

int i = 1;

do {

printf("%d\n", i);

i++;

} while(i <= 5);

Chapter 6: Functions

#include <stdio.h>

int add(int a, int b); // Declaration

int main() {

printf("Sum = %d\n", add(5, 10));

return 0;

int add(int a, int b) { // Definition

return a + b;

Chapter 7: Arrays and Strings

int numbers[5] = {1, 2, 3, 4, 5};

for(int i=0; i<5; i++) {

printf("%d\n", numbers[i]);

String Example

char name[] = "C Language";

printf("Hello %s\n", name);


Chapter 8: Pointers

#include <stdio.h>

int main() {

int a = 10;

int *p = &a;

printf("Value: %d\n", a);

printf("Address: %p\n", p);

printf("Value using pointer: %d\n", *p);

return 0;

Chapter 9: Structures

#include <stdio.h>

struct Student {

char name[20];

int age;

float marks;

};

int main() {

struct Student s1 = {"Rahul", 18, 89.5};

printf("Name: %s\nAge: %d\nMarks: %.2f\n", [Link], [Link], [Link]);

return 0;

Chapter 10: File Handling


#include <stdio.h>

int main() {

FILE *f;

f = fopen("[Link]", "w");

fprintf(f, "Hello, File Handling in C!");

fclose(f);

return 0;

Practice Exercises

1. Print your name, age, and hobby.

2. Check whether a number is even or odd.

3. Find the sum of two numbers.

4. Display multiplication table of a number.

5. Find factorial using loops.

6. Reverse a string using functions.

7. Find largest element in an array.

8. Swap two numbers using pointers.

9. Store details of students using structures.

10. Create and read data from a file.

Mini Projects in C

Project 1: Simple Calculator

#include <stdio.h>

int main() {

char op;

double a, b;

printf("Enter operator (+, -, *, /): ");

scanf(" %c", &op);


printf("Enter two numbers: ");

scanf("%lf %lf", &a, &b);

switch(op) {

case '+': printf("Result = %.2lf\n", a + b); break;

case '-': printf("Result = %.2lf\n", a - b); break;

case '*': printf("Result = %.2lf\n", a * b); break;

case '/':

if(b != 0) printf("Result = %.2lf\n", a / b);

else printf("Error: Division by zero!\n");

break;

default: printf("Invalid operator!\n");

return 0;

Project 2: Number Guessing Game

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

int main() {

int num, guess, attempts = 0;

srand(time(0));

num = rand() % 100 + 1; // Random number between 1-100

do {

printf("Guess the number (1-100): ");

scanf("%d", &guess);

attempts++;
if(guess > num) printf("Too high!\n");

else if(guess < num) printf("Too low!\n");

else printf("Correct! You guessed it in %d attempts.\n", attempts);

} while(guess != num);

return 0;

Project 3: Student Management System

#include <stdio.h>

struct Student {

int id;

char name[50];

float marks;

};

int main() {

int n;

printf("Enter number of students: ");

scanf("%d", &n);

struct Student s[n];

for(int i=0; i<n; i++) {

printf("\nEnter details of student %d\n", i+1);

printf("ID: "); scanf("%d", &s[i].id);

printf("Name: "); scanf("%s", s[i].name);

printf("Marks: "); scanf("%f", &s[i].marks);

}
printf("\n--- Student Records ---\n");

for(int i=0; i<n; i++) {

printf("ID: %d, Name: %s, Marks: %.2f\n", s[i].id, s[i].name, s[i].marks);

return 0;

Project 4: Tic-Tac-Toe Game (2 Players)

#include <stdio.h>

char board[3][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'} };

void printBoard() {

printf("\n");

for(int i=0; i<3; i++) {

for(int j=0; j<3; j++) {

printf(" %c ", board[i][j]);

if(j < 2) printf("|");

if(i < 2) printf("\n---|---|---\n");

printf("\n");

int checkWin() {

for(int i=0; i<3; i++)

if(board[i][0]==board[i][1] && board[i][1]==board[i][2]) return 1;

for(int i=0; i<3; i++)

if(board[0][i]==board[1][i] && board[1][i]==board[2][i]) return 1;

if(board[0][0]==board[1][1] && board[1][1]==board[2][2]) return 1;


if(board[0][2]==board[1][1] && board[1][1]==board[2][0]) return 1;

return 0;

int main() {

int choice, player = 1, moves = 0;

char mark;

do {

printBoard();

mark = (player == 1) ? 'X' : 'O';

printf("Player %d, enter your choice: ", player);

scanf("%d", &choice);

int row = (choice-1) / 3, col = (choice-1) % 3;

if(board[row][col] != 'X' && board[row][col] != 'O') {

board[row][col] = mark;

moves++;

if(checkWin()) {

printBoard();

printf("Player %d wins!\n", player);

return 0;

player = (player == 1) ? 2 : 1;

} else {

printf("Invalid move! Try again.\n");

} while(moves < 9);

printBoard();
printf("It's a draw!\n");

return 0;

You might also like