Write a c program to accept the 10 numbers from user store these number in array and sort the array in ascending order using DMA

#include<stdio.h>
#include<conio.h>
void main()
{
int *ip,i=0,j=0;
int n,t=0;
clrscr();
printf("\n enter the array limit\n");
scanf("%d",&n);
ip=(int*)malloc(n*sizeof(int));
printf("\n enter the array elements \n");
for(i=0;i<n;i++)
{
scanf("%d",&ip[i]);
}
printf("\n enter  array elements  are\n");
for(i=0;i<n;i++)
{
printf("\t%d",ip[i]);
printf("\n");
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(ip[i]>ip[j])
{
t=ip[i];
ip[i]=ip[j];
ip[j]=t;
}
}
}
for(i=0;i<n;i++)
{
printf("\n sorting of array =%d\n",ip[i]);
}
getch();
}

Comments

  1. accept 10 number from the user and find out there some and product.

    ReplyDelete
  2. write a program to accept number from user and display positive if the number is > 0 and < 0 if negative

    ReplyDelete

Post a Comment