C Programming Notes and Practical Guide
Part A: Theory Notes
Detailed explanations of programming language generations, language processors, algorithms,
flowcharts, basics of C, operators, type conversion, decision and loop control structures.
Part B: Practical Coding Section
Includes all fundamental and special C programs with solutions and explanations.
Basic Input/Output Programs
1. Print a message
2. Add two numbers
3. Swap two numbers
4. Find ASCII value of a character
Decision Control Programs
1. Check even or odd
2. Check positive, negative, or zero
3. Largest among three numbers
4. Check leap year
5. Calculator using switch
Loop Control Programs
1. Print 1 to n
2. Sum of n natural numbers
3. Reverse a number
4. Factorial of a number
5. Count digits
6. Sum of digits
7. Multiplication table
Series and Special Number Programs
1. Fibonacci Series
2. Palindrome Number
3. Armstrong Number
4. Krishnamurthy Number
5. Perfect Number
6. Prime Number
7. Reverse String
Example: Fibonacci Series
#include <stdio.h> int main() { int n, t1 = 0, t2 = 1, next; printf("Enter the number of terms: ");
scanf("%d", &n;); printf("Fibonacci Series: "); for(int i = 1; i <= n; ++i) { printf("%d ", t1); next = t1 +
t2; t1 = t2; t2 = next; } return 0; } Output:
Enter number of terms: 6
Fibonacci Series: 0 1 1 2 3 5
Example: Check Armstrong Number
#include <stdio.h> #include <math.h> int main() { int n, temp, rem, sum = 0, digits = 0; printf("Enter
a number: "); scanf("%d", &n;); temp = n; while (temp != 0) { temp /= 10; digits++; } temp = n; while
(temp != 0) { rem = temp % 10; sum += pow(rem, digits); temp /= 10; } if (sum == n)
printf("Armstrong number"); else printf("Not an Armstrong number"); return 0; } Output:
Enter a number: 153
Armstrong number
Example: Krishnamurthy (Strong) Number
#include <stdio.h> int fact(int n) { int f = 1; for(int i = 1; i <= n; i++) f *= i; return f; } int main() { int n,
temp, rem, sum = 0; printf("Enter a number: "); scanf("%d", &n;); temp = n; while (temp != 0) { rem =
temp % 10; sum += fact(rem); temp /= 10; } if (sum == n) printf("Krishnamurthy number"); else
printf("Not a Krishnamurthy number"); return 0; } Output:
Enter a number: 145
Krishnamurthy number