0

C Program to subtract two matrices.

#include<stdio.h> #include<conio.h> void main() { int i,j,a[5][5],b[5][5],m,n,sum; clrscr(); printf(“Enter the number of rows and columns for matrices:(max 5)”); scanf(“%d%d”,&m,&n); printf(“Enter the elements of first matrix”); for(i=0;i<m;i++) {  for(j=0;j<n;j++)   {    scanf(“%d”,&a[i][j]);   } } printf(“Enter the elements of second matrix”); for(i=0;i<m;i++) {… Continue Reading

0

C program to add two matrices.

#include<stdio.h> #include<conio.h> void main() { int i,j,a[5][5],b[5][5],m,n,sub; clrscr(); printf(“Enter the number of rows and columns for matrices:(max 5)”); scanf(“%d%d”,&m,&n); printf(“Enter the elements of first matrix”); for(i=0;i<m;i++) {  for(j=0;j<n;j++)   {    scanf(“%d”,&a[i][j]);   } } printf(“Enter the elements of second matrix”); for(i=0;i<m;i++) {… Continue Reading

0

Bubble Sort in java

void bubbleSort(int[] arr) {   boolean swapped = true;   for(int i = 0; i < arr.length-1; i++) {     swapped = false;     for(int j = 0; j < arr.length-i-1; j++) {       if(arr[j] > arr[j+1]) {         int temp = arr[j];         arr[j] = arr[j+1];         arr[j+1] = temp;         swapped = true;       }     }     if(swapped == false)       break;   } }

0

Bubble Sort

In bubble sort there is a comparison between two adjacent elements and then if the values are not in order  then swapping takes place. The process takes place until no swapping is needed. This is called bubble sort because as… Continue Reading