Category Archives: Basic C Programs for Beginners

Python Heart Shape Star Pattern Program

Python Heart Shape Star Pattern Program This Python pattern printing program uses the logic of the following figure. We can see that how the stars are present in certain positions. We will create some conditions on the basis of star posittion in each row. For example we consider the first row which is zero row.… Read More »

 138 total views,  5 views today

C Program Display and Count Odd Numbers in Array

C Program Display and Count Odd Numbers in Array /* C Program to display and count all odd numbers in array www.EasyCodeBook.com */ #include <stdio.h> int main() { int array[100],i,n, count=0; printf(“Enter number of elements in array = “); scanf(“%d”, &n); printf(“Enter %d numbers in array\n”, n); for (i = 0; i < n; i++)… Read More »

 14 total views,  1 views today

C Program Find Sum of Even Numbers in Array

C Program Find Sum of Even Numbers in Array /* C Program to Find Sum of Even numbers in array www.EasyCodeBook.com */ #include <stdio.h> int main() { int array[100],i,n, sum=0; printf(“Enter number of elements in array = “); scanf(“%d”, &n); printf(“Enter %d numbers in array\n”, n); for (i = 0; i < n; i++) {… Read More »

 22 total views

C Program Count Frequency of Each Element in Array

C Program Count Frequency of Each Element in Array This C Program will Find Number of Occurences of Every Element in Array. /* C Program to Count frequencies of each element of an array of numbers www.EasyCodeBook.com */ #include <stdio.h> int main() { int array[100], array2[100], n, i, j, element, count;; printf(“Enter number of elements… Read More »

 27 total views

C Program Sum of Main Diagonal of Square Matrix

C Program Sum of Main Diagonal of Square Matrix   /* Write a C program to input a Square matrix of m rows and m columns and displaying the sum of the main diagonal elements from top left corner to right bottom corner. www.easycodebook.com */ #include <stdio.h> int main() { int sqmatrix[10][10]; int i,j,m,sum=0; printf(“The… Read More »

 19 total views,  1 views today

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 »

 42 total views,  1 views today

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 »

 28 total views,  1 views today

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 »

 9 total views,  1 views today

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 »

 10 total views

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 »

 13 total views,  2 views today