C Program Matrix Input Output

C Program Matrix Input Output /* Write a C program to input a m x n matrix and displaying in matrix format www.easycodebook.com */ #include <stdio.h> int main() { int matrix[10][10]; int i,j,m,n; printf(“Enter number of Rows [10 Maximum]:”); scanf(“%d”,&m); printf(“Enter number of Columns [10 Maximum:]:”); scanf(“%d”,&n); printf(“\nEnter %d matrix elements in %d x %d… Read More »

Loading

C Program Binary to Decimal Number

C Program Binary to Decimal Number Converter   /* Write a C program to input a binary number, and convert into correspondin Decimal number www.easycodebook.com */ #include<stdio.h> #include<math.h> int main() { long int binNum,rem,n,i,decimal; printf(“Enter a Binary Number:”); scanf(“%ld”,&binNum); i=0; decimal=0; for(n=binNum;n!=0;n=n/10) { rem=n%10; decimal=decimal+rem*pow(2,i); i++; } printf(“Decimal Number:%ld “,decimal); return 0; } Output 1:… Read More »

Loading

C Program Find Larger Value between Two variables

C Program Find Larger Value between Two variables /* Find larger value between two variable www.easycodebook.com */ #include<stdio.h> int main() { int n1,n2; printf(“Enter value of N1: “); scanf(“%d”,&n1); printf(“Enter value of N2: “); scanf(“%d”,&n2); if(n1>n2) printf(“N1 is larger”); else if(n2>n1) printf(“N2 is larger”); else printf(“Both numbers are equal”); return 0; } Output 1: Enter… Read More »

Loading

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 »

Loading

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 »

Loading

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 »

Loading

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 »

Loading

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 »

Loading

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 »

Loading