C Program To Arrange the numbers in ascending and descending order

C Program To Arrange the numbers in ascending and descending order

C
Loading...

C Program To Arrange the numbers in ascending and descending order – C Programming Me Ham Arrange The Numbers In Ascending And Descending Order Program Ko Create Karne Wale Hai, Jo Ye Program Array Or For Loop Se Banayenge |

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

To Arrange the numbers in ascending and descending order

What is Ascending Order In Hindi – Ascending Order Ka Matlab Hota Hai, Jaise 1 Se 10 Number Ko 1,2,3,4,5,6,7,8,9,10 Is Tarah Se Lagana |

What is Descending Order in Hindi – Descending Order Ka Matlab Hota Hai, Jaise 1 Se 10 Number Ko Is Tarah Se Lagana 10,9,8,7,6,5,4,3,2,1 |

Example:

#include<stdio.h>
#include<conio.h>
int main()
{
	int a[10],temp,i,j,size;

	printf("\nEnter the array size : ");
	scanf("%d",&size);

	printf("\nEnter the array to be sorted : ");
	for(i=0;i<size;i++)
	{
		scanf("%d",&a[i]);
	}

	for(i=0;i<size;i++)
	{
		for(j=i+1;j<size;j++)
		{
			if(a[i]>a[j])
			{
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}

	}

	printf("\n\nSorted Array in ascending order : ");
	for(i=0;i<size;i++)
	{
		printf("%d ",a[i]);
	}

	printf("\n\nSorted Array in descending order : ");
	for(i=size-1;i>=0;i--)
	{
		printf("%d ",a[i]);
	}

getch();
}

Output:

Enter the array size : 5

Enter the array to be sorted : 5 1 3 2 4


Sorted Array in ascending order : 1 2 3 4 5

Sorted Array in descending order : 5 4 3 2 1

More Practice Program:

Friends Mujhe Umeed Hai Ki Aapko C Language Program To Arrange the numbers in ascending and descending order In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

MasterPrograming Apps

Leave a Reply

Your email address will not be published.