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


Please Help Members By Posting Answers For Below Questions

what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

1933


What is the explanation for cyclic nature of data types in c?

652


What is null in c?

602


Is fortran faster than c?

587


Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant

671






how many key words availabel in c a) 28 b) 31 c) 32

636


Why calloc is better than malloc?

574


In a byte, what is the maximum decimal number that you can accommodate?

629


What is the function of multilevel pointer in c?

675


Write a program to identify if a given binary tree is balanced or not.

691


What is extern variable in c with example?

544


What is main () in c language?

605


What is the benefit of using #define to declare a constant?

611


Write a program to print fibonacci series using recursion?

591


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1433