Sunday, January 25, 2015

FUNCTIONS WITH ARGUMENTS & WITHOUT RETURN TYPE

PROGRAM:

#include<stdio.h>


void sorting(int a[],int n)
{

int i,j,t; for(i=0;i<n-1;i++)

{

for(j=i+1;j<n;j++)
{

if(a[i]>a[j])
{

t=a[i];
a[i]=a[j];

a[j]=t;
}
}

}

printf("Array Elemets before sorting\n"); for(i=0;i<n;i++)

printf("%d\t",a[i]);



main()

{



int i,a[10],n;

printf("Enter total no. of elements\n"); scanf("%d",&n);

printf("Enter Array Elements one by one\n"); for(i=0;i<n;i++)

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

printf("Array Elemets before sorting\n"); for(i=0;i<n;i++)

printf("%d\t",a[i]);

printf("\n");


sorting(a,n);
}

OUTPUT:

Enter total no. of elements 6

Enter Array Elements one by one 21 2


45





30





11





Array Elemets before sorting

21
2
9
45
30
11
Array Elemets before sorting

2
9
11
21
30
45

No comments:

Post a Comment