mid sem c practical lab nitk b3 batch qstn 1

#include<stdio.h>
void main()
{
 int array[10];
 int n,i,j,temp;
 printf("\n enter the no of element you want to insert");
 scanf("%d",&n);
 printf("\n enter the element");
 for(i=0;i<n;i++)
 {
    scanf("%d",&array[i]);
 }
 for(i=0;i<n;i++)
 {
   for(j=1;j<n-i;j++)
   {
     if(array[i]>array[i+j])
     {
     temp=array[i];
     array[i]=array[i+j];
     array[i+j]=temp;
  }
   }
 }
 i=0;
 printf("array[i]+array[j]=%d",array[i]+array[i+1]);
}

Comments

Popular posts from this blog

BYTE STUFFING PROGRAM USING C

Rotate a matrix 270 degree AntiClockWise

Finding the length of connected cells of 1's (regions) in an matrix of 1's and 0's