write a program to arrange the contents of a 1D array in
ascending order
Answer Posted / rajeev
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,j,temp;
clrscr();
printf("\n enter the size of the array");
scanf("%d",&n);
printf("\n enter the contents of the array");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<(n-1)-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
getch();
}
| Is This Answer Correct ? | 10 Yes | 12 No |
Post New Answer View All Answers
Can you explain the four storage classes in C?
Why can arithmetic operations not be performed on void pointers?
What is the purpose of void pointer?
Mention four important string handling functions in c languages .
Is there any possibility to create customized header file with c programming language?
Write a program to print "hello world" without using a semicolon?
Explain two-dimensional array.
Differentiate between the expression “++a” and “a++”?
Write a program to reverse a linked list in c.
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
Is multithreading possible in c?
Why string is used in c?
What is #define size in c?
Explain why C language is procedural?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference