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 are pointers? What are different types of pointers?
What are directives in c?
How is null defined in c?
What is the maximum no. of arguments that can be given in a command line in C.?
What is return in c programming?
Tell us bitwise shift operators?
What are the characteristics of arrays in c?
Explain zero based addressing.
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What are the different types of control structures?
Why is it that not all header files are declared in every C program?
What is a struct c#?
Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
What is dynamic dispatch in c++?