answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

Program to sort numbers in c plus plus?

/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i<N-1;i++) for(int j=i+1;j<N-1-i;j++) if(n[j]>n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i<N;i++) { v=n[j]; for(int j=i-1;j>0&&n[j]>v;j--) n[j+1]=n[j]; n[j+1]=v; } */


C program to check whether a given matrix is orthogonal or not?

#include<iostream> #include<stdio.h> #include<conio.h> using namespace std; int main() { int a[20][20],b[20][20],c[20][20],i,j,k,m,n,f; cout << "Input row and column of A matrix \n\n"; cin >> n >> m; cout << "\n\nInput A - matrix \n\n"; for(i=0;i<n;++i) for(j=0;j<m;++j) cin >> a[i][j]; cout << "\n\nMatrix A : \n\n"; for(i=0;i<n;++i) { for(j=0;j<m;++j) cout << a[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;++i) for(j=0;j<n;++j) b[i][j]=a[j][i]; cout << "\n\nTranspose of matrix A is : \n\n"; for(i=0;i<m;++i) { for(j=0;j<n;++j) cout << b[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;i++) { for(j=0;j<m;j++){ c[i][j]=0; for(k=0;k<=m;k++) c[i][j]+=a[i][k]*b[k][j]; } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { if((int)c[i][i]==1&&(int)c[i][j]==0) f=1; } } cout<<"\n\n Matrix A * transpose of A \n\n"; for(i=0;i<m;i++) { for(j=0;j<m;j++) cout << c[i][j]; cout << "\n\n"; } if(f==1) cout << "\n\nMatrix A is Orthogonal !!!"; else cout << "\n\nMatrix A is NOT Orthogonal !!!"; getch(); return 0; } -ALOK


Program for row wise sort for a square matrix in C?

#include<stdio.h> #include<conio.h> void main() { int a[10][10],i,j,k,m,n; printf("enter the order"); scanf("%d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } for(k=0;k<m;k++) { for(i=0;i<=m-1;i++) { for(j=0;j<n-i-1;j++) { if(a[k][j]>a[k][j+1]) temp=a[k][j]; a[k][j]=a[k][j+1]; a[k][j+1]=temp; } } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("sorted matrix=%d",a[i][j]); } } getch(); }


C program for solving gauss seidal method?

#include<stdio.h> int main() { double matrix[10][10],a,b, temp[10]; int i, j, k, n; printf("Enter the no of variables: "); scanf("%d", &n); printf("Enter the agumented matrix:\n"); for(i = 0; i < n ; i++){ for(j = 0; j < (n+1); j++){ scanf("%lf", &matrix[i][j]); } } for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ if(j>i){ a = matrix[j][i]; b = matrix[i][i]; for(k = 0; k < n+1; k++){ matrix[j][k] = matrix[j][k] - (a/b) * matrix[i][k]; } } } } printf("The Upper triangular matrix is: \n"); for( i = 0; i < n; i++){ for(j = 0; j < n+1; j++){ printf("%.2f", matrix[i][j]); printf("\t"); } printf("\n"); } printf("\nThe required result is: "); for(i = n-1; i>=0; i--){ b = matrix[i][n]; for(j = n-1 ; j > i; j--){ b -= temp[n-j]*matrix[i][j]; } temp[n-i] = b/matrix[i][i]; printf("\n%c => %.2f",97+i, temp[n-i]); } }


How you get a code of Radix sort?

#include<stdio.h> void radix(int a[],int n) { int i,j,k=1,l,temp,b[10][n],cnt; int max=a[0],c=0; for(i=0;i<n;i++) if(a[i]>max) max=a[i]; while(max%10) { c++; max/=10; } for(i=0;i<10;i++) for(j=0;j<n;j++) b[i][j]=-999; for(l=0;l<c;l++) { for(j=0;j<n;j++) { temp=(a[j]/k)%10; b[temp][j]=a[j]; } k=k*10; cnt=0; for(i=0;i<10;i++) for(j=0;j<n;j++) if(b[i][j]!=-999) a[cnt++]=b[i][j]; for(i=0;i<10;i++) for(j=0;j<n;j++) b[i][j]=-999; } } main() { int i,n; printf("Enter array capacity \t: "); scanf("%d",&n); int a[n]; for(i=0;i<n;i++) a[i]=rand()%100; printf("\nArray Before Sorting : "); for(i=0;i<n;i++) printf("%4d",a[i]); radix(a,n); printf("\n\nArray After Sorting : "); for(i=0;i<n;i++) printf("%4d",a[i]); printf("\n"); }

Related Questions

What is the difference between fluxs J and N in mass transfer?

In mass transfer, flux is the amount of mass flowing through a unit area per unit time. Flux is represented by the symbol "J" and can be either molar flux (J) or mass flux (N). Molar flux (J) is the amount of moles of a component flowing through a unit area per unit time, while mass flux (N) is the amount of mass of a component flowing through a unit area per unit time. The key difference between the two is that molar flux is expressed in moles per unit area per unit time, while mass flux is expressed in kilograms per unit area per unit time.


What is the flux linkage formula used to calculate the total magnetic flux passing through a coil of wire?

The flux linkage formula used to calculate the total magnetic flux passing through a coil of wire is given by the equation N, where represents the magnetic flux, N is the number of turns in the coil, and is the magnetic flux per turn.


Program to sort numbers in c plus plus?

/* Bubble sort: code snippet only nos to be sorted are in the array named 'n' of size 'N' for(int i=0;i<N-1;i++) for(int j=i+1;j<N-1-i;j++) if(n[j]>n[j+1]) swap(n[j],n[j+1]); */ /* insertion sort int v,j; for(int i=1;i<N;i++) { v=n[j]; for(int j=i-1;j>0&&n[j]>v;j--) n[j+1]=n[j]; n[j+1]=v; } */


Distance vector routing in c program?

#include<stdio.h> int main() { int n,i,j,k,a[10][10]; printf("\nEnter the number of nodes: "); scanf("%d",&n); for(i=0; i<n; i++) { for(j=0; j<n; j++) { printf("\nEnter the distance between the host %d%d:", i+1,j+1); scanf("%d",&a[i][j]); } } for(i=0; i<n; i++) { for(j=0; j<n; j++) printf("%d\t",a[i][j]); printf("\n"); } for(k=0; k<n; k++) { for(i=0; i<n; i++) { for(j=0; j<n; j++) { if(a[i][j]>a[i][k]+a[k][j]) a[i][j]=a[i][k]+a[k][j]; } } } for(i=0; i<n; i++) { for(j=0; j<n; j++) { b[i][j]=a[i][j]; if(i==j) b[i][j]=0; } } printf("\nThe output matrix is:\n"); for(i=0;i<n;i++) { for(j=0;j<n;j++) printf("%d\t",b[i][j]); printf("\n"); } return 0; }


C program to check whether a given matrix is orthogonal or not?

#include<iostream> #include<stdio.h> #include<conio.h> using namespace std; int main() { int a[20][20],b[20][20],c[20][20],i,j,k,m,n,f; cout << "Input row and column of A matrix \n\n"; cin >> n >> m; cout << "\n\nInput A - matrix \n\n"; for(i=0;i<n;++i) for(j=0;j<m;++j) cin >> a[i][j]; cout << "\n\nMatrix A : \n\n"; for(i=0;i<n;++i) { for(j=0;j<m;++j) cout << a[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;++i) for(j=0;j<n;++j) b[i][j]=a[j][i]; cout << "\n\nTranspose of matrix A is : \n\n"; for(i=0;i<m;++i) { for(j=0;j<n;++j) cout << b[i][j] << " "; cout << "\n\n"; } for(i=0;i<m;i++) { for(j=0;j<m;j++){ c[i][j]=0; for(k=0;k<=m;k++) c[i][j]+=a[i][k]*b[k][j]; } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { if((int)c[i][i]==1&&(int)c[i][j]==0) f=1; } } cout<<"\n\n Matrix A * transpose of A \n\n"; for(i=0;i<m;i++) { for(j=0;j<m;j++) cout << c[i][j]; cout << "\n\n"; } if(f==1) cout << "\n\nMatrix A is Orthogonal !!!"; else cout << "\n\nMatrix A is NOT Orthogonal !!!"; getch(); return 0; } -ALOK


Program for row wise sort for a square matrix in C?

#include<stdio.h> #include<conio.h> void main() { int a[10][10],i,j,k,m,n; printf("enter the order"); scanf("%d",&m,&n); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&a[i][j]); } } for(k=0;k<m;k++) { for(i=0;i<=m-1;i++) { for(j=0;j<n-i-1;j++) { if(a[k][j]>a[k][j+1]) temp=a[k][j]; a[k][j]=a[k][j+1]; a[k][j+1]=temp; } } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("sorted matrix=%d",a[i][j]); } } getch(); }


C program for solving gauss seidal method?

#include<stdio.h> int main() { double matrix[10][10],a,b, temp[10]; int i, j, k, n; printf("Enter the no of variables: "); scanf("%d", &n); printf("Enter the agumented matrix:\n"); for(i = 0; i < n ; i++){ for(j = 0; j < (n+1); j++){ scanf("%lf", &matrix[i][j]); } } for(i = 0; i < n; i++){ for(j = 0; j < n; j++){ if(j>i){ a = matrix[j][i]; b = matrix[i][i]; for(k = 0; k < n+1; k++){ matrix[j][k] = matrix[j][k] - (a/b) * matrix[i][k]; } } } } printf("The Upper triangular matrix is: \n"); for( i = 0; i < n; i++){ for(j = 0; j < n+1; j++){ printf("%.2f", matrix[i][j]); printf("\t"); } printf("\n"); } printf("\nThe required result is: "); for(i = n-1; i>=0; i--){ b = matrix[i][n]; for(j = n-1 ; j > i; j--){ b -= temp[n-j]*matrix[i][j]; } temp[n-i] = b/matrix[i][i]; printf("\n%c => %.2f",97+i, temp[n-i]); } }


What is a c code to implement heap sort?

#include<stdio.h> #include<conio.h> int a[25],n,i; void maxheapify(int,int); void buildmaxheap(); void main() { int temp; clrscr(); printf("\n\t\t\t\tHEAP SORT"); printf("\n\t\t\t\t**** ****\n\n\n"); printf("\n Enter no of elements:"); scanf("%d",&n); printf("\n Enter elements to be sorted\n\n"); for(i=1;i<=n;i++) scanf("%d",&a[i]); buildmaxheap(); for(i=n;i>=2;i--) { temp=h[1]; a[1]=a[i]; a[i]=temp; maxheapify(1,i-1); } printf("\n SORTED ELEMENT\n\n"); for(i=1;i<=n;i++) printf("%d\n",a[i]); getch(); } void buildmaxheap() { int i; for(i=n/2;i>=1;i--) maxheapify(i,n); } void maxheapify(int i,int n) { int j,element; j=2*i; element=a[i]; while(j<=n) { if((j<n)&&(a[j]<a[j+1])) j=j++; if(element>=a[j]) break; a[j/2]=a[j]; j=2*j; } a[j/2]=element; }


Where can I find information on a painting signed J Bertrand?

go to wikipedia.org and type your query there! or go to google images n type it there


Write a program in C to multiply matrix?

//to multiply two matrices... #include<stdio.h> main() { int a[4][4]; int b[4][4]; int c[4][4]; int i,j,k; printf("\n Enter elements into the first matix....\n"); for(i=0;i<4;i++) { for(j=0;j>4;j++) { scanf("%d",&a[i][j]); } } printf("\n Enter elements into the second matrix.....\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) { scanf("%d",&b[i][j]); } } printf("\n 1st Matrix.....\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("\t%d",a[i][j]); } printf("\n"); } printf("\n 2nd Matrix......\n); for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("\t%d",b[i][j]); } printf("\n"); } for(i=0;i<4;i++) { for(j=0;j<4;j++) { for(k=0;k<4;k++) { c[i][j]+=(a[i][k]*b[k][j]); } } } printf("\n Resultant Matrix...\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) { printf("\t%d",c[i][j]); } printf("\n"); } }


How do you write a program in C to ascend n numbers?

#include <stdio.h> main() { int n,i,j,a[10][10],t; clrscr(); printf("enter the limit of an array\n"); scanf("%d",&n); printf("enter the elments of an array\n"); for(i=1;i<=n;i++) scanf("%d",&a[i]); for(j=1;j<=n-i;j++) scanf("%d",&[j+1]) { t=a[j]; a[j]=a[j+1]=t; } printf("the numbers after sorting are:\n"); for(i=1;i<=n;i++) printf("%d\t",a[i]); getch(); }


How you get a code of Radix sort?

#include<stdio.h> void radix(int a[],int n) { int i,j,k=1,l,temp,b[10][n],cnt; int max=a[0],c=0; for(i=0;i<n;i++) if(a[i]>max) max=a[i]; while(max%10) { c++; max/=10; } for(i=0;i<10;i++) for(j=0;j<n;j++) b[i][j]=-999; for(l=0;l<c;l++) { for(j=0;j<n;j++) { temp=(a[j]/k)%10; b[temp][j]=a[j]; } k=k*10; cnt=0; for(i=0;i<10;i++) for(j=0;j<n;j++) if(b[i][j]!=-999) a[cnt++]=b[i][j]; for(i=0;i<10;i++) for(j=0;j<n;j++) b[i][j]=-999; } } main() { int i,n; printf("Enter array capacity \t: "); scanf("%d",&n); int a[n]; for(i=0;i<n;i++) a[i]=rand()%100; printf("\nArray Before Sorting : "); for(i=0;i<n;i++) printf("%4d",a[i]); radix(a,n); printf("\n\nArray After Sorting : "); for(i=0;i<n;i++) printf("%4d",a[i]); printf("\n"); }