C Programming Notes
Module I – Introduction to C Language
1. History of C Language
- C language was developed by Dennis Ritchie in 1972 at Bell Labs.
- C is called a middle-level language.
Importance of C
- Fast and efficient
- Portable language
- Used in system programming
Sample Program
#include <stdio.h>
int main()
{
printf("Hello World");
return 0;
}
2. Character Set, Tokens, Constants, Variables and Data Types
Character Set
- Alphabets
- Digits
- Special symbols
Tokens
- Keywords
- Identifiers
- Constants
- Operators
Data Types
- int
- float
- char
- double
3. Operators in C
Arithmetic Operators
+ - * / %
Relational Operators
== != > < >= <=
Logical Operators
&& || !
Conditional Operator
condition ? expression1 : expression2;
Bitwise Operators
& | ^ ~ << >>
4. Managing Input and Output
scanf() – formatted input
printf() – formatted output
getchar() – read character
putchar() – write character
Decision Making Statements
- if
- if else
- nested if
- else if ladder
- switch
Loops
- while
- do while
- for loop
- nested loop
Jump Statements
- break
- continue
Arrays
One-dimensional array
Two-dimensional array
Multi-dimensional array
Strings
Functions:
strlen()
strcpy()
strcmp()
strcat()
Functions
- Function declaration
- Function definition
- Function call
- Call by value
- Call by reference
- Recursion
Storage Classes
- auto
- register
- static
- extern
Structure and Union
- Structure declaration
- Arrays of structures
- Nested structures
- Union
Pointers
- Pointer declaration
- Pointer initialization
- Pointer arithmetic
- Pointers and arrays
- Pointers and functions
Dynamic Memory Allocation
Functions:
malloc()
calloc()
realloc()
free()
Important Viva Questions
1. What is C language?
2. What are tokens?
3. Difference between structure and union?
4. What is recursion?
5. What is pointer?