# Category Archives: Basic C Programs for Beginners

## C Program Find Teranspose Matrix

C Program Find Teranspose Matrix   /* C program to find Transpose of a Matrix www.easycodebook.com */ #include <stdio.h> int main() { int m, n, i, j, matrix1[10][10], transpose[10][10]; printf(“Enter the number of rows and columns of the matrix[Maximum 10]:\n”); scanf(“%d%d”, &m, &n); printf(“Please Enter %d elements Row wise in (%d rows x %d columns)… Read More »

## C Program Matrix Multiplication

C Program Matrix Multiplication /* C program to multiplication two matrices Matrix Multiplication www.easyCodeBook.com */ #include <stdio.h> int main() { int m, n, p, q, i, j, k; int matrix1[10][10], matrix2[10][10], multiplication[10][10]; printf("Enter number of rows and columns of matrix1\n"); scanf("%d%d", &m, &n); printf("Enter number of rows and columns of matrix2\n"); scanf("%d%d", &p, &q); if… Read More »

## C Program Subtract Two Matrices

C Program Subtract Two Matrices /* C program to subtract two matrices www.easycodebook.com */ #include <stdio.h> int main() { int m, n, i, j, matrix1[10][10], matrix2[10][10], subtraction[10][10]; printf(“Enter the number of rows and columns of matrix\n”); scanf(“%d%d”, &m, &n); printf(“Please Enter %d elements of first matrix\n”,m*n); for (i = 0; i < m; i++) for… Read More »

## C Program Add Two Matrix

C Program Add Two Matrix /* C program to add two matrices www.easycodebook.com */ #include <stdio.h> int main() { int m, n, i, j, matrix1[10][10], matrix2[10][10], sum[10][10]; printf(“Enter the number of rows and columns of matrix\n”); scanf(“%d%d”, &m, &n); printf(“Please Enter %d elements of first matrix\n”,m*n); for (i = 0; i < m; i++) for… Read More »

## C Program Find Sum of Digits of N

C Program Find Sum of Digits of N This C language program will input a number n from the user. It will use the divide the number by 10 logic and remainder logic to find the sum of all the digits of that number provided by the user. How Sum of Digits program works? Let… Read More »

## C Program Sort N Strings in Ascending Order

C Program Sort N Strings in Ascending Order /* C program to input n strings and sort them in ascending order alphabetically */ #include <stdio.h> #include <string.h> int main() { char str[30][40],temp[30]; int n,i,j; printf(“\nString Sorting: Sorts N strings:\n”); printf(“************************************\n”); printf(“Input number of strings :”); scanf(“%d”,&n); getchar(); printf(“Input string %d :\n”,n); for(i=0;i<n;i++) gets(str[i]); /*Logic for… Read More »

## C Program Find Substring Index in String

C Program Find Substring Index in String /* C program to input Source string and a search substring to be searched in first string. And displaying found or not, using string function strstr(). */ #include <stdio.h> #include <string.h> int main() { char str[100]; char search[50]; char *ptr; printf("Enter a string:\n"); gets(str); printf("Enter search substring:\n"); gets(search);… Read More »

## C Program String Concatenation using strcat

C Program String Concatenation using strcat /* C program to input two strings and concatenating the second string at end of first string using strcat() predefined string function. */ #include <stdio.h> #include <string.h> int main() { char str1[100], str2[100]; printf("Enter the first string\n"); gets(str1); printf("Enter the second string\n"); gets(str2); strcat(str1, str2); printf("String obtained after concatenation\nusing… Read More »

## C Program Case Insensitive String Comparison

C Program Case Insensitive String Comparison USING stricmp() built-in string function /* C program to input two strings and check whether both strings are the same (equal) or not using stricmp() predefined function. stricmp() gives a case insensitive comparison. www.easycodebook.com */ #include <stdio.h> #include <string.h> int main() { char str1[100], str2[100]; printf(“Enter first string for… Read More »

## C Program Compare String using strcmp

C Program Compare String using strcmp /* C program to input two strings and check whether both strings are the same (equal) or not using strcmp() predefined function. strcmp() gives a case sensitive comparison. www.easycodebook.com */ #include <stdio.h> #include <string.h> int main() { char str1[100], str2[100]; printf(“Enter first string\n”); gets(str1); printf(“Enter second string\n”); gets(str2); if… Read More »