0% found this document useful (0 votes)
58 views18 pages

Full C Programming Notes 50 Pages

Uploaded by

manivajrala26
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)
58 views18 pages

Full C Programming Notes 50 Pages

Uploaded by

manivajrala26
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
You are on page 1/ 18

Complete C Programming Notes with Examples

Chapter 1: Introduction to C

- C is a powerful, general-purpose programming language.

- It supports structured programming and low-level memory access.

- Ideal for developing firmware and portable applications.

Example:

#include <stdio.h>

int main() {

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

return 0;

Chapter 2: Data Types and Variables

- Basic Data Types: int, float, char, double

- Modifiers: short, long, signed, unsigned

Example:

int age = 30;

float weight = 65.5;

char grade = 'A';

Chapter 3: Operators

- Arithmetic, Relational, Logical, Bitwise, Assignment, Increment/Decrement

Example:

int a = 5, b = 2;

printf("a + b = %d\n", a + b);

Chapter 4: Control Flow

Page 1
Complete C Programming Notes with Examples

- if, if-else, nested if, switch-case

Example:

int num = 10;

if (num > 0) {

printf("Positive\n");

} else {

printf("Non-positive\n");

Chapter 5: Loops

- for, while, do-while

Example:

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

printf("%d ", i);

Chapter 6: Functions

- Declaration, Definition, Call, Return

- Call by value and call by reference

Example:

int square(int x) {

return x * x;

Chapter 7: Arrays

- One-dimensional and multi-dimensional arrays

Page 2
Complete C Programming Notes with Examples

Example:

int arr[3] = {1, 2, 3};

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

printf("%d ", arr[i]);

Chapter 8: Strings

- Declaring and manipulating strings

- Standard string functions: strcpy, strlen, strcat

Example:

char name[20] = "John";

printf("Name: %s\n", name);

Chapter 9: Pointers

- Basics of pointers, pointer arithmetic, pointers and arrays

Example:

int x = 5;

int *p = &x;

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

Chapter 10: Structures and Unions

- Defining and using structures

Example:

struct Point {

int x, y;

Page 3
Complete C Programming Notes with Examples

};

struct Point p1 = {0, 1};

Chapter 11: File Handling

- fopen, fclose, fprintf, fscanf, fread, fwrite

Example:

FILE *f = fopen("file.txt", "w");

fprintf(f, "Hello\n");

fclose(f);

Chapter 12: Dynamic Memory Allocation

- malloc, calloc, realloc, free

Example:

int *ptr = (int *)malloc(5 * sizeof(int));

free(ptr);

Chapter 13: Recursion

- Recursive function calls

Example:

int factorial(int n) {

if(n==0) return 1;

return n * factorial(n-1);

Chapter 14: Preprocessor Directives

Page 4
Complete C Programming Notes with Examples

- #define, #include, #ifdef, #ifndef

Example:

#define PI 3.1416

#include <stdio.h>

Chapter 15: C Standard Library

- stdio.h, stdlib.h, string.h, math.h

Example:

#include <math.h>

printf("%f\n", sqrt(16));

Chapter 1: Introduction to C

- C is a powerful, general-purpose programming language.

- It supports structured programming and low-level memory access.

- Ideal for developing firmware and portable applications.

Example:

#include <stdio.h>

int main() {

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

return 0;

Chapter 2: Data Types and Variables

- Basic Data Types: int, float, char, double

- Modifiers: short, long, signed, unsigned

Page 5
Complete C Programming Notes with Examples

Example:

int age = 30;

float weight = 65.5;

char grade = 'A';

Chapter 3: Operators

- Arithmetic, Relational, Logical, Bitwise, Assignment, Increment/Decrement

Example:

int a = 5, b = 2;

printf("a + b = %d\n", a + b);

Chapter 4: Control Flow

- if, if-else, nested if, switch-case

Example:

int num = 10;

if (num > 0) {

printf("Positive\n");

} else {

printf("Non-positive\n");

Chapter 5: Loops

- for, while, do-while

Example:

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

printf("%d ", i);

Page 6
Complete C Programming Notes with Examples

Chapter 6: Functions

- Declaration, Definition, Call, Return

- Call by value and call by reference

Example:

int square(int x) {

return x * x;

Chapter 7: Arrays

- One-dimensional and multi-dimensional arrays

Example:

int arr[3] = {1, 2, 3};

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

printf("%d ", arr[i]);

Chapter 8: Strings

- Declaring and manipulating strings

- Standard string functions: strcpy, strlen, strcat

Example:

char name[20] = "John";

printf("Name: %s\n", name);

Page 7
Complete C Programming Notes with Examples

Chapter 9: Pointers

- Basics of pointers, pointer arithmetic, pointers and arrays

Example:

int x = 5;

int *p = &x;

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

Chapter 10: Structures and Unions

- Defining and using structures

Example:

struct Point {

int x, y;

};

struct Point p1 = {0, 1};

Chapter 11: File Handling

- fopen, fclose, fprintf, fscanf, fread, fwrite

Example:

FILE *f = fopen("file.txt", "w");

fprintf(f, "Hello\n");

fclose(f);

Chapter 12: Dynamic Memory Allocation

- malloc, calloc, realloc, free

Example:

Page 8
Complete C Programming Notes with Examples

int *ptr = (int *)malloc(5 * sizeof(int));

free(ptr);

Chapter 13: Recursion

- Recursive function calls

Example:

int factorial(int n) {

if(n==0) return 1;

return n * factorial(n-1);

Chapter 14: Preprocessor Directives

- #define, #include, #ifdef, #ifndef

Example:

#define PI 3.1416

#include <stdio.h>

Chapter 15: C Standard Library

- stdio.h, stdlib.h, string.h, math.h

Example:

#include <math.h>

printf("%f\n", sqrt(16));

Chapter 1: Introduction to C

- C is a powerful, general-purpose programming language.

Page 9
Complete C Programming Notes with Examples

- It supports structured programming and low-level memory access.

- Ideal for developing firmware and portable applications.

Example:

#include <stdio.h>

int main() {

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

return 0;

Chapter 2: Data Types and Variables

- Basic Data Types: int, float, char, double

- Modifiers: short, long, signed, unsigned

Example:

int age = 30;

float weight = 65.5;

char grade = 'A';

Chapter 3: Operators

- Arithmetic, Relational, Logical, Bitwise, Assignment, Increment/Decrement

Example:

int a = 5, b = 2;

printf("a + b = %d\n", a + b);

Chapter 4: Control Flow

- if, if-else, nested if, switch-case

Page 10
Complete C Programming Notes with Examples

Example:

int num = 10;

if (num > 0) {

printf("Positive\n");

} else {

printf("Non-positive\n");

Chapter 5: Loops

- for, while, do-while

Example:

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

printf("%d ", i);

Chapter 6: Functions

- Declaration, Definition, Call, Return

- Call by value and call by reference

Example:

int square(int x) {

return x * x;

Chapter 7: Arrays

- One-dimensional and multi-dimensional arrays

Example:

Page 11
Complete C Programming Notes with Examples

int arr[3] = {1, 2, 3};

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

printf("%d ", arr[i]);

Chapter 8: Strings

- Declaring and manipulating strings

- Standard string functions: strcpy, strlen, strcat

Example:

char name[20] = "John";

printf("Name: %s\n", name);

Chapter 9: Pointers

- Basics of pointers, pointer arithmetic, pointers and arrays

Example:

int x = 5;

int *p = &x;

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

Chapter 10: Structures and Unions

- Defining and using structures

Example:

struct Point {

int x, y;

};

struct Point p1 = {0, 1};

Page 12
Complete C Programming Notes with Examples

Chapter 11: File Handling

- fopen, fclose, fprintf, fscanf, fread, fwrite

Example:

FILE *f = fopen("file.txt", "w");

fprintf(f, "Hello\n");

fclose(f);

Chapter 12: Dynamic Memory Allocation

- malloc, calloc, realloc, free

Example:

int *ptr = (int *)malloc(5 * sizeof(int));

free(ptr);

Chapter 13: Recursion

- Recursive function calls

Example:

int factorial(int n) {

if(n==0) return 1;

return n * factorial(n-1);

Chapter 14: Preprocessor Directives

- #define, #include, #ifdef, #ifndef

Page 13
Complete C Programming Notes with Examples

Example:

#define PI 3.1416

#include <stdio.h>

Chapter 15: C Standard Library

- stdio.h, stdlib.h, string.h, math.h

Example:

#include <math.h>

printf("%f\n", sqrt(16));

Chapter 1: Introduction to C

- C is a powerful, general-purpose programming language.

- It supports structured programming and low-level memory access.

- Ideal for developing firmware and portable applications.

Example:

#include <stdio.h>

int main() {

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

return 0;

Chapter 2: Data Types and Variables

- Basic Data Types: int, float, char, double

- Modifiers: short, long, signed, unsigned

Example:

int age = 30;

Page 14
Complete C Programming Notes with Examples

float weight = 65.5;

char grade = 'A';

Chapter 3: Operators

- Arithmetic, Relational, Logical, Bitwise, Assignment, Increment/Decrement

Example:

int a = 5, b = 2;

printf("a + b = %d\n", a + b);

Chapter 4: Control Flow

- if, if-else, nested if, switch-case

Example:

int num = 10;

if (num > 0) {

printf("Positive\n");

} else {

printf("Non-positive\n");

Chapter 5: Loops

- for, while, do-while

Example:

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

printf("%d ", i);

Page 15
Complete C Programming Notes with Examples

Chapter 6: Functions

- Declaration, Definition, Call, Return

- Call by value and call by reference

Example:

int square(int x) {

return x * x;

Chapter 7: Arrays

- One-dimensional and multi-dimensional arrays

Example:

int arr[3] = {1, 2, 3};

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

printf("%d ", arr[i]);

Chapter 8: Strings

- Declaring and manipulating strings

- Standard string functions: strcpy, strlen, strcat

Example:

char name[20] = "John";

printf("Name: %s\n", name);

Chapter 9: Pointers

- Basics of pointers, pointer arithmetic, pointers and arrays

Page 16
Complete C Programming Notes with Examples

Example:

int x = 5;

int *p = &x;

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

Chapter 10: Structures and Unions

- Defining and using structures

Example:

struct Point {

int x, y;

};

struct Point p1 = {0, 1};

Chapter 11: File Handling

- fopen, fclose, fprintf, fscanf, fread, fwrite

Example:

FILE *f = fopen("file.txt", "w");

fprintf(f, "Hello\n");

fclose(f);

Chapter 12: Dynamic Memory Allocation

- malloc, calloc, realloc, free

Example:

int *ptr = (int *)malloc(5 * sizeof(int));

free(ptr);

Page 17
Complete C Programming Notes with Examples

Chapter 13: Recursion

- Recursive function calls

Example:

int factorial(int n) {

if(n==0) return 1;

return n * factorial(n-1);

Chapter 14: Preprocessor Directives

- #define, #include, #ifdef, #ifndef

Example:

#define PI 3.1416

#include <stdio.h>

Chapter 15: C Standard Library

- stdio.h, stdlib.h, string.h, math.h

Example:

#include <math.h>

printf("%f\n", sqrt(16));

Page 18

You might also like