Program on array manipulations using c, array manipulations in C, C array manupulations

Program on array manipulations using c, array manipulations in C

#include

main()

{

int a[20],b[20],n,i,j,temp,sb,ss,sbp,ssp;

clrscr();

printf("ENTER HOW MANY ELEMENTS\n");

scanf("%d",&n);

printf("ENTER %d ELEMENTS\n",n);

for (i=0;i

scanf("%d",&a[i]);

for (i=0;i

b[i]=a[i];

for (i=0;i

{

for (j=i+1;j

if (a[i]

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}
}
sb=a[1];
ss=a[n-2];
for (i=0;i
{
for (j=i+1;j
{
if (b[i]==sb)
sbp=i;
if (b[i]==ss)
ssp=i;
}
}
b[sbp]=ss;

b[ssp]=sb;

printf("AFTER INTERCHANGING THE SECOND BIGGEST ELEMENT AND\n");

printf("THE SECOND SMALLEST ELEMENT THE ARRAY IS\n");

for (i=0;i

printf("%d\n",b[i]);

getch();

}











No comments:

Post a Comment