0% found this document useful (0 votes)
37 views1 page

C Beginner Notes

C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972, known for its efficiency and use in system programming. The document covers the structure of a simple C program, data types, variables, operators, control structures, functions, arrays, pointers, and input/output functions. It also provides tips for beginners to enhance their programming skills in C.

Uploaded by

ac1260332
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)
37 views1 page

C Beginner Notes

C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972, known for its efficiency and use in system programming. The document covers the structure of a simple C program, data types, variables, operators, control structures, functions, arrays, pointers, and input/output functions. It also provides tips for beginners to enhance their programming skills in C.

Uploaded by

ac1260332
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/ 1

C Programming Basics – Beginner Notes

1. What is C? - C is a general-purpose, procedural programming language. - Developed by Dennis


Ritchie in 1972 at Bell Labs. - It is fast, efficient, and widely used for system programming,
embedded systems, etc.

2. Structure of a Simple C Program: #include int main() { printf("Hello, World!\n"); return 0; } -


#include includes standard input-output functions. - int main() is the main function where execution
starts. - printf() prints output. - return 0; returns success code to OS.

3. Data Types in C: - int (4 bytes): int age = 20; - char (1 byte): char letter = 'A'; - float (4 bytes): float
price = 5.99; - double (8 bytes): double pi = 3.14159; - void: Used for functions with no return.

4. Variables and Constants: - Variable Declaration: int age; float price; char letter; - Assigning
Values: age = 25; price = 99.99; letter = 'C'; - Constants: const int DAYS_IN_WEEK = 7;

5. Operators: - Arithmetic: + - * / % - Comparison: == != > < >= <= - Logical: && || ! - Assignment: =
+= -= *= /= %=

6. Control Structures: - If-Else: if (age > 18) { printf("Adult\n"); } else { printf("Minor\n"); } - Switch
Case: switch(option) { case 1: printf("Option 1\n"); break; default: printf("Invalid option\n"); } - Loops:
For loop: for(int i=0;i<5;i++){ printf("%d\n", i); } While loop: while(i<5){ printf("%d\n", i); i++; }
Do-While loop: do { printf("%d\n", i); i++; } while(i<5);

7. Functions in C: Example: #include int add(int a, int b); int main() { int result = add(5,3);
printf("Result: %d\n", result); return 0; } int add(int a, int b) { return a + b; }

8. Arrays: int numbers[5] = {1,2,3,4,5}; printf("%d\n", numbers[0]); // Output: 1

9. Pointers: int a = 10; int *p = &a; printf("%d\n", *p); // Output: 10

10. Input/Output Functions: printf("Enter your age: "); scanf("%d", &age;); printf("You are %d years
old.\n", age);

Tips for Beginners: - Always include #include . - End each statement with a semicolon. - Practice
small programs. - Understand variables, functions, arrays. - Debug carefully.

You might also like