C Program to Calculate the Sum of Digits of a given Integer

Write a program in C to calculate the Sum of Digits of a given Number

C Program to Accept two Integers and Check if they are Equal

Write a program in C to accept two integers and check if they are equal

C Program to Read Two Integers and Swap their Values

Write a program in C to read two integers and swap their values.

C Program to Find the Number of Integers Divisible by 3

C Program to find number of integers divisible by 3

C Program to Check if a given Integer is Positive or Negative

Check whether the entered number is positive or negative using C Program

C Program to Calculate the Sum of Odd and Even Numbers

In this C Program we are going to calculate the sum of even and odd numbers in between 1 to N

C Program to Check if a given Integer is Odd or Even

C program to check whether the input number is even or odd.

C program to sort a list of numbers using Insertion Sort

/*Insertion sort in ascending order*/ #include<conio.h> #include<stdio.h> int main() { int n, array[100], c,d,t; printf(“Enter number of elements\n”); scanf(“%d”,&n); printf(“Enter %d integers\n”,n); for(c=0;c<n;c++) scanf(“%d”, &array[c]); for(c=1;c<=n-1;c++) { d=c; while(d>0 && array[d]<array[d-1]) { t=array[d]; array[d]=array[d-1]; array[d-1]=t; d–; } } printf(“Sorted list in ascending order:\n”); for(c=0;c<n;c++) printf(“%d\n”, array[c]); return 0; }

C program to sort a list of numbers using Bubble Sort

#include<conio.h> #include<stdio.h> int main() { int array[100], n, c, d, swap; printf(“Enter number of elements\n”); scanf(“%d”, &n); printf(“Enter %d integers \n”,n); for(c=0;c<n;c++) { for(d=0;d<(n-c-1);d++) { if(array[d]>array[d+1]) { swap=array[d]; array[d]=array[d+1]; array[d+1]=swap; } } } printf(“Sorted list in ascending order:\n”); for(c=0;c<n;c++) printf(“%d\n”, array[c]); return 0; }

C program to sort an array using Selection Sort

#include<conio.h> #include<stdio.h> int main() { int array[100],n,c,d,position,swap; printf(“Enter number of elements\n”); scanf(“%d”, &n); printf(“Enter %d integers\n”,n); for(c=0;c<n;c++) scanf(“%d”, &array[c]); for(c=0;c<(n-1);c++) { position=c; for(d=c+1;d<n;d++) { if(array[position]>array[d]) position=d; } if(position!=c) { swap=array[c]; array[c]=array[position]; array[position]=swap; } } printf(“Sorted list in ascending order:\n”); for(c=0;c<n;c++) printf(“%d\n”, array[c]); return 0; }

C program to search an integer in a given list using Binary Search

C program to search an integer in a given list using Binary Search

C program to add, subtract and multiply two complex numbers using structure

#include<conio.h> #include<stdio.h> #include<stdio.h> struct complex { int real, img; }; int main() { int choice; struct complex a,b,c; while(1) { printf(“Press 1 to add two complex numbers.\n”); printf(“Press 2 to subtract two complex numbers.\n”); printf(“Press 3 to multiply two complex numbers.\n”); printf(“Press 4 to exit.\n”); printf(“Enter your choice.\n”); scanf(“%d”,&choice); if(choice==4) exit(0); if(choice>=1 && choice<=3) { […]

C program to multiply and subtract two matrices.

#include<conio.h> #include<stdio.h> int main() { int m,n,p,q,c,d,k,sum=0; int first[10][10], second[10][10], multiply[10][10], difference[10][10]; printf(“Enter the number of rows and column of first matrix \n”); scanf(“%d%d”, &m,&n); printf(“Enter the elements of first matrix\n”); for(c=0;c<m;c++) for(d=0;d<n;d++) scanf(“%d” &first[c][d]); printf(“Enter the number of rows and column of second matrix\n”); scanf(“%d%d”, &p,&q); if(n!=p) { printf(“Matrices with entered orders cannot be […]

How to assign value to a variable and read the value in C

1 2 3 4 5 6 7 8 9 #incude<conio.h> #include<stdio.h> void main() { int n; scanf(“%d”,&n);//Assigning value to variable ‘n’ at run time printf(“%d”,n);// Reading or printing the value of ‘n’ getch(); }