jituTechnology

jituTechnology

A program to sort the data in ascending order using separate function to read, sort and display.

A program to sort the data in ascending order using separate function to read, sort and display.

Codes
/*A program to sort the data in ascending order using function*/
/*Programed by          Jitendra Kr Yadav
                         10116
     22 Mar,2011*/
#include<stdio.h>
#include<conio.h>
void read(int num[],int);
void sort(int num[],int);
void display(int num[],int);
main()
{
int n[20],x;
read(n,x);
sort(n,x);
display(n,x);
getch();
}
void read(int num[],int n)
{
int i;
printf(“Enter the number of data to input: “);
scanf(“%d”,&n);
printf(“Enter the data:\n”);
for(i=0;i<n;i++)
scanf(“%d”,&num[i]);
}
void sort(int num[], int n)
{
int i,j,temp;
for(i=0;i<=n-1;i++)
for(j=i+1;j<=n-1;j++)
if(num[i]>num[j])
{
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
void display(int num[],int n)
{
int i;
printf(“\n”);
printf(“The Ascending  Order is\n”);
for(i=0;i<n;i++)
printf(“%d\t”,num[i]);
}
Output
Enter the number of data to input: 5
Enter the data:
5
6
4
2
1
The Ascending Order is
1          2          4          5          6
Press any key to continue…
Add a comment

Comments (1)

  1. Etsuko KetterApril 6, 2012 Reply
    Pretty portion of content. I just stumbled upon your website and in accession capital to claim that I acquire actually loved account your blog posts. Anyway I’ll be subscribing to your augment or even I success you get right of entry to consistently fast.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

October 2019
S M T W T F S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031