[go: up one dir, main page]

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

C Programming Notes

This document provides quick notes on C programming for first-semester students, covering features, program structure, data types, operators, control statements, loops, arrays, strings, functions, pointers, structures, and file handling. It also includes examples and a list of important programs to practice. Key distinctions between compilers and interpreters are highlighted, along with various programming concepts essential for understanding C.

Uploaded by

a.h.bershy2007
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 views3 pages

C Programming Notes

This document provides quick notes on C programming for first-semester students, covering features, program structure, data types, operators, control statements, loops, arrays, strings, functions, pointers, structures, and file handling. It also includes examples and a list of important programs to practice. Key distinctions between compilers and interpreters are highlighted, along with various programming concepts essential for understanding C.

Uploaded by

a.h.bershy2007
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/ 3

C Programming – Quick Notes for 1st Semester

Features of C Language
- General purpose, structured, mid-level language.
- Portable and efficient.
- Supports modular programming (functions).
- Rich library of operators and functions.
- Used for system programming and applications.

Structure of a C Program
A C program has:
1. Preprocessor directives (#include <stdio.h>).
2. main() function (starting point).
3. Variable declarations.
4. Statements and logic.
5. Return statement.

Example:
#include <stdio.h>
int main() {
int a=5,b=10,sum;
sum=a+b;
printf("Sum=%d",sum);
return 0;
}

Compiler vs Interpreter
- Compiler: Translates entire program at once (C uses compiler).
- Interpreter: Executes line by line (Python uses interpreter).

Data Types in C
Basic: int, float, char, double
Derived: arrays, pointers, structures, functions
Void: no value

Example:
int age=20;
float marks=85.5;
char grade='A';

Operators in C
Arithmetic: +, -, *, /, %
Relational: >, <, ==, !=
Logical: &&, ||, !
Assignment: =

Control Statements
- if, if-else, nested if
- switch-case
- break, continue, goto
Loops
- for loop
- while loop
- do-while loop

Arrays
Collection of same data type stored in contiguous memory.
Example: int marks[5]={90,80,70,85,95};

Strings
Character array ending with null ('\0').
Common functions: strlen, strcpy, strcmp, strcat

Functions
Block of reusable code.
Types: Library functions, User-defined functions.
Call by Value: Copy of variable passed.
Call by Reference: Address passed, original changes.

Pointers
Stores address of another variable.
Example:
int a=10;
int *p;
p=&a;

Structures
Collection of different data types under one name.
Example:
struct Student {
int roll;
char name[20];
float marks;
};

File Handling
Functions: fopen, fclose, fprintf, fscanf
Modes: r (read), w (write), a (append)

Important Programs
1. Print your name, age, branch.
2. Add two numbers.
3. Find simple and compound interest.
4. Area of circle/rectangle/triangle.
5. Even or Odd number check.
6. Largest of 3 numbers.
7. Grade system using if-else.
8. Calculator using switch.
9. Multiplication table.
10. Factorial of a number.
11. Fibonacci series.
12. Reverse a number.
13. Prime number check.
14. Sum & average of array elements.
15. Matrix addition and multiplication.
16. Largest element in array.
17. Count vowels in string.
18. Palindrome string check.
19. Swap numbers using function & pointers.
20. Student record using structures.

You might also like