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 is nested structure in c?
Explain what is operator promotion?
What is pre-emptive data structure and explain it with example?
What is a example of a variable?
Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above
Why do we use return in c?
Is r written in c?
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
What is floating point constants?
What is const and volatile in c?
List a few unconditional control statement in c.
Explain what is wrong with this program statement? Void = 10;
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
Write a program to print ASCII code for a given digit.
Can the “if” function be used in comparing strings?