Accept 10 numbers and store in an array, print sorted array in descending and ascending order:
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
{
for(j=i+1;j<10;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<10;i++)
printf(" %d ",a[i]);
printf(" Nos sorted in ascending order\n");
printf("\n");
for(i=9;i>=0;i--)
printf(" %d ",a[i]);
printf(" Nos sorted in descending order\n");
getch();
}
Subscribe to:
Post Comments (Atom)
Related Post
Array:
String functions:
General (Loops-for/while)
Hi, Nice Program for Sorting An Array.Thanks, its really helped me......
ReplyDelete-Aparna
Theosoft
MERGE SORT, BUBBLE SORT, HEAP SORT, INSERTION SORT, QUICK SORT and other types of sorting at :
ReplyDeletehttp://thec-language.blogspot.in/p/blog-page_23.html
Best C Programs with Complete Explanation ..
ReplyDeleteVisit To Code ►► Lightning Code
Useful programming for beginners.
ReplyDeletesap gold partner
SAP Partners
SAP Implementation
HANA Technology
SCM with SAP
This comment has been removed by the author.
ReplyDeleteC tutorial with free and simple example on Data Types & Variables, Conditionals, Loops, Arrays & Strings etc. Here you can download simple and easy online c tutorial for beginners .C Programming online test.
ReplyDeleteGood
ReplyDeleteHere is a link for C/C++ programs and pointer programs. This may be useful for you.
C Programs
C++ Programs
Go on cproinfo.blogspot.com
ReplyDeleteFor all programs,interview questions and examples
To know the programming technique: "Make Your Program Trial Version in C" visit:
ReplyDeleteudebayan.blogspot.com
To know the programming technique: "Make Your Program Trial Version in C" visit:
ReplyDeleteudebayan.blogspot.com
This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.
ReplyDeleteLove from
ReplyDeleteThis blog is awesome,thanks for ur valuable inforamtion ,u want more inforamtion about C programming languages join C programming classes in bangalore,visit : Aptech computer education,my tage are :
C training bangalore,C courses bangalore,C classes bangalore,C institute bangalore,C coaching centers bangalore,C programming institute in bangalore,C programming classes in bangalore
thanks for creating a nice post on c programming but did you know what is loop in c programming
ReplyDeleteReally a great post, i really impressed with your blog, thanks for sharing!!
ReplyDeleteDevOps Online Training
very informative Uses of C language
ReplyDeletethanks for sharing this c programming examples with output
ReplyDeleteGreat piece of informative post
ReplyDeleteUses of C programming
Write a C program to print all prime number between 1 to 300 using for loop.
ReplyDeleteCode of given problem:
int main()
{
int a,b;
printf("List of prime numbers between 1 to 300:\n");
printf("%d\t",a=2);
for(a=1;a<=300;a++)
{
for(b=2;b<=a-1;b++)
if(a%b==0)
break;
else if(b==a-1)
{
printf("%d\t",a);
}
}
return 0;
}
Very informative blog!
Please take some time to visit my blog @
Top 10 programming examples in C
Thanks!
Nice program
DeleteAngularjs Online Training India
Nice blog
ReplyDeleteAngularjs Online Training India
do my homework JavaScript
ReplyDelete