0% found this document useful (0 votes)
8 views4 pages

C Programming Notes

This document provides basic notes on C programming, covering its introduction, structure, tokens, data types, variables, operators, input/output, control structures, functions, arrays, strings, pointers, structures, file handling, and preprocessor directives. It also includes example programs and practice exercises for further learning. The notes serve as a foundational guide for understanding and applying C programming concepts.

Uploaded by

dipakasd41
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)
8 views4 pages

C Programming Notes

This document provides basic notes on C programming, covering its introduction, structure, tokens, data types, variables, operators, input/output, control structures, functions, arrays, strings, pointers, structures, file handling, and preprocessor directives. It also includes example programs and practice exercises for further learning. The notes serve as a foundational guide for understanding and applying C programming concepts.

Uploaded by

dipakasd41
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 Basic Notes

1. Introduction to C Programming
• C is a general-purpose procedural programming language developed by Dennis Ritchie in 1972.
• Features: Simple, structured, portable, machine-independent, rich library functions.
• Applications: OS, compilers, embedded systems, games, system programming.

2. Structure of a C Program

#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

- #include <stdio.h> → Standard I/O library. - main() → Entry point. - printf() → Output. -
return 0; → End program successfully.

3. C Tokens
• Keywords: int, return, if, else, for
• Identifiers: Names of variables/functions
• Constants: Fixed values (10, 'a')
• Operators: +, -, *, /, %
• Special symbols: ;, {}, (), []

4. Data Types
• Basic: int, float, double, char
• Derived: arrays, pointers, structures
• Void type: no value

5. Variables and Constants


• Variable: stores data
• Rules: start with letter/underscore, no keyword, can contain letters/digits/_
• Constant: cannot change

const int MAX = 100;

1
6. Operators
• Arithmetic: +, -, *, /, %
• Relational: ==, !=, >, <, >=, <=
• Logical: &&, ||, !
• Assignment: =, +=, -=, *=, /=
• Increment/Decrement: ++, --
• Conditional: ?:

7. Input and Output

int num;
printf("Enter a number: ");
scanf("%d", &num);
printf("You entered %d", num);

8. Control Structures
8.1 Conditional Statements
• if, if-else, if-else if-else, switch-case

8.2 Loops
• for, while, do-while

9. Functions
• Definition: Block of code for specific task

int add(int a, int b) {


return a + b;
}
int main() {
int sum = add(5,10);
printf("%d", sum);
}

10. Arrays
• Collection of same type elements

2
int arr[5] = {1,2,3,4,5};
printf("%d", arr[0]);

11. Strings
• Array of characters ending with \0

char str[20] = "Hello";


printf("%s", str);

• Functions: strlen(), strcpy(), strcat(), strcmp()

12. Pointers
• Variable storing address

int a = 10;
int *ptr = &a;
printf("%d", *ptr);

13. Structures
• User-defined data type

struct Student {
char name[50];
int roll;
float marks;
};
struct Student s1 = {"Deepak",101,88.5};

14. File Handling


• Modes: r, w, a

FILE *fp;
fp = fopen("[Link]", "w");
fprintf(fp, "Hello File");
fclose(fp);

3
15. Preprocessor Directives

include, #define, #ifdef, #endif

16. Example Programs


1. Sum of two numbers
2. Even/Odd check
3. Factorial
4. Fibonacci series
5. Simple calculator (switch-case)
6. Palindrome check
7. Reverse string
8. Largest among three numbers
9. Prime number check
10. Array sum

17. Practice Exercises


• Write programs for basic arithmetic, loops, arrays, and string manipulation.
• Use functions and pointers in small projects.
• File handling: create, read, write, append.

End of Notes

You might also like