write a program to sort the elements in a given array in c
language
Answer Posted / hguyiyo
#include<stdio.h>
main()
{
int i, count=0;
int n,num,t;
scanf("%d",&n);
int a[n];
while(count!=n)
{
scanf("%d",&num);
a[count]=num;
++count;
}
for(i=0;i<n;++i) printf(" %d ",a[i]);
printf("\n\n\n\n");
for(i=0;i<n;++i)
if(a[i]<=a[i+1]) ;
else
{
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
for(i=0;i<n;++i) printf(" %d ",a[i]);
}
| Is This Answer Correct ? | 4 Yes | 8 No |
Post New Answer View All Answers
What does 3 periods mean in texting?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
What does the && operator do in a program code?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
What is the use of a ‘ ’ character?
how can use subset in c program and give more example
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What is the use of pointers in C?
What's the best way of making my program efficient?
Can the curly brackets { } be used to enclose a single line of code?
How to write c functions that modify head pointer of a linked list?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
Differentiate between calloc and malloc.
What is action and transformation in spark?