Programming Tools

where students meet to knowledge

Month

December 2016

What is Sparse Matrix? “Sparse Matrix is a matrix which contains very few non-zero elements”. A matrix can be defined with a 2-dimensional array. Any array with ‘m’ columns and ‘n’ rows represents a m*n matrix. There may be a… Continue Reading →

Find an element from Array using Linear search

#include<stdio.h> void main() { int a[10],i,n,flag=0,k; printf(“Enter element of an array\n”); for(i=0;i<10;i++) { scanf(“%d”,&a[i]); } printf(“Enter the number which you want to search\n”); scanf(“%d”,&n); for(i=0;i<10;i++) { if(a[i]==n) { flag=1; k=i; break; } } if(flag==1) { printf(“Number is found at %d… Continue Reading →

Transpose of given Array

#include<stdio.h> void main() { int m,n,i,j,mat[10][10],transp[10][10]; printf(“Enter the number of rows and cols\n”); scanf(“%d”,&m,&n); printf(“Enter the element of matrix\n”); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf(“%d”,&mat[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { transp[j][i]=mat[i][j]; } } printf(“Transpose of entered matrix is\n”); for(i=0;i<m;i++) {… Continue Reading →

Difference between Second maximum and second minimum In Array

#include<stdio.h> void main() { int a[10],i,max1,max2,min1,min2,s,k,d; printf(“Enter element of array\n”); for(i=0;i<10;i++) { scanf(“%d”,&a[i]); } max1=min1=a[0]; for(i=0;i<10;i++) { if(a[i]>max1) { s=i; if(a[i]<min1) { k=i; } } d=a[s]; d[s]=a[9]; a[9]=d; d=a[k]; a[k]=a[8]; a[8]=d; max2=min2=a[0]; for(i=0;i<8;i++) { if(a[i]>max2) { max2=a[i]; } if(a[i]<min2) {… Continue Reading →

Average of First Five Maximum Numbers In Array

#include<stdio.h> int main() { int i,j,max,sum=0,temp,a[10]; float avg; printf(“Enter element of array\n”); for(i=0;i<10;i++) { scanf(“%d”,&a[i]); } for(i=0;i<5;i++)¬† { max=0; for(j=0;j<10;j++) { if(a[j]>max) { max=a[j]; temp=j; } } a[temp]=0; sum=sum+max; } avg=sum/5;s printf(“%f is average”,avg); return 0; }

Threaded Binary Tree

A Binary tree is Threaded by making all right child pointers that would normally be ‘\0’¬†point to the inorder successor of the node (if it exists), and all left child pointers that would normally be ‘\0’ point to the inorder… Continue Reading →

© 2017 Programming Tools — acadinetech.com