/*A program for insertion sort of an array using user input without function
Author: Abdullah Bin Kasem Bhuiyan
Email: jehadfeni@gmail.com
*/
#include
int main()
{
//Declaration of array and relevant variables
int A[3],i;
for(i=0; i<3 aking="" array="" d="" element:="" from="" i="" input="" int="" j="" ninput="" orting="" printf="" scanf="" the="" user="" while="">0 && A[j-1]>A[j])
{
int temp = A[j-1];
A[j-1]=A[j];
A[j]=temp;
j--;
}
}
//printing the sorted array
printf("\nPrinted Array: \n");
for(i=0; i<3; i++)
{
printf("%d\n",A[i]);
}
return 0;
}
No comments:
Post a Comment