answersLogoWhite

0

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

int main(void)

{

int *a,n,i,j,t;

printf("enter the array size");

scanf("%d",&n);

if (n<=0) exit (11);

a= malloc (n*sizeof (a[0]));

if (a==NULL) exit (12);

printf("enter the elements of an array");

for(i=0;i<n;i++)

{

scanf("%d",a[i]);

}

for(i=0;i<n;i++)

{

for(j=i+1;j<n;j++)

{

if(a[i]>a[j])

{

t=a[i];

a[i]=a[j];

a[j]=t;

}

}

}

for(i=0;i<n;i++)

{

printf("%d",a[i]);

}

getch();

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.


Write a C programme to find out sum of the array elements?

main(){int n,a[i],s;s=0;printf("enter no of elements in array");scanf("%d",&n);printf("Enter elements in array");for(i=;i


How do you write a programme in c language using arrays to store a ten integer data and find the second smallest and second largest elements in the array?

void mail ( ); { int a, b c = a+b; printf ("%d",=c); }


How do you write a programme in c language using arrays to copy diagonal elements of a 2-d array into a 1-d array?

TO use a c language first step is to know about the c language and the steps to use the c progrmming language with the help of any elders or with the teachers. TO use the arrays you have to get th eknowledge of "c" language


How can we create an unsized array to c programme?

Use a pointer... int a*; a = malloc(sizeof(int)*100); //allocate space for 100 elements free(a); a = malloc(sizeof(int)*1000); // allocate space for 1000 elements free(a);


How can I get the number of elements in an array in C?

Ah, honey, in C, you can get the number of elements in an array by dividing the total size of the array by the size of one element. So, if you have an array of integers, you can do something like int size = sizeof(array) / sizeof(array[0]); and voilà, you've got the number of elements. Just be careful with those pesky pointers and make sure you're not trying to count elements in a pointer instead of an actual array.


What is the code of sorting out an given unsorted array in text file for c plus plus?

Sorting arrays (of any type) can be achieved with the C++ standard library std::sort function: std::array&lt;int, 5&gt; a {9, 3, 5, 1, 7}; // fixed-length array std::vector&lt;int&gt; b {9, 3, 5, 1, 7}; // variable length array int c[] = {9, 3, 5, 1, 7}; // C-style array std::sort (a.begin(), a.end()); std::sort (b.begin(), b.end()); std::sort (c, c+5);


Program in c to delete an element in sorted array?

You cannot delete elements from an array. But you can move the elements: if (del_index &lt; no_of_elements-1) { memmove (&amp;array [del_index], &amp;array [del_index+1], sizeof (array [0]) * (no_of_elements - del_index - 1)); } --no_of_elements;


How can I get the size of an array in C?

To get the size of an array in C, you can use the sizeof() operator. This operator returns the number of bytes occupied by the array, so to get the number of elements in the array, you can divide the total size by the size of one element.


Sorting an array in PHP without using sort function?

plz as soon as possible give me the program for shorting an array in asscending order without using any sort function in c++


How do you accept values of array of structure from user in c?

How do you accept total no of array elements and values from the user in c?


Can you help me with the C plus plus code of the program which has 10 index of array it adds 5 into every even elements of the array and then it subtracts 10 into the odd elements of the array?

int array[10] = {...}; for (int i = 0; i &lt; 10; ++i) { if (i % 2 == 0) array[i] += 5; else array[i] -= 10; }