Category Archives: Basic C Programs C Source Code

C Function Kilo Bytes to Bytes

C Function Kilo Bytes to Bytes – C Program to convert kilo bytes into bytes using a user defined function. Source Code   #include <stdio.h> int kb2byte(int kb) { return kb * 1024; } int main() { int k,b; printf(“Enter Kilo Bytes to convert into Bytes:”); scanf(“%d”,&k); b = kb2byte(k); printf(“%d KB = %d Bytes”,k,b);… Read More: C Function Kilo Bytes to Bytes »

Loading

Count Digits in String C Program

Count Digits in String C Program – Input a string containing both digits and alphabets. This program in C language will display the count of digits in the given string. Source Code /* * C program to count the digits present in the given string */ #include <stdio.h> void main() { char str[100]; int i,count=0;… Read More: Count Digits in String C Program »

Loading

Display Yearly Calendar C Program

Topic: Display Yearly Calendar C Program First of all this c program will require a four digit year to input. As soon as the use enters a correct year for example, 2020, this c program will display calendar of the year 2020 month wise. This c program to display calendar uses smaller modules called functions… Read More: Display Yearly Calendar C Program »

Loading

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: C Program Display and Count Odd Numbers in Array »

Loading

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: C Program Find Sum of Even Numbers in Array »

Loading

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: C Program Count Frequency of Each Element in Array »

Loading

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: C Program Sum of Main Diagonal of Square Matrix »

Loading

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: C Program Matrix Input Output »

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: C Program Binary to Decimal Number »

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: C Program Find Larger Value between Two variables »

Loading