Write a C program to arrange 10 numbers in ascending order.
#include <stdio.h>
int main() {
int a[10], i, j, temp;
printf("Enter 10 numbers:\n");
for (i = 0; i < 10; i++) {
scanf("%d", &a[i]);
}
for (i = 0; i < 9; i++) {
for (j = i+1; j < 10; j++) {
if (a[i] > a[j]) {
temp = a[i];
arr[i] = a[j];
a[j] = temp;
}
}
}
printf("Numbers in ascending order:\n");
for (i = 0; i < 10; i++) {
printf("%d ", a[i]);
}
return 0;
}
Structures in Cis a user-defined data type available in C that allows to combining of data items of different kinds. Structures are used to represent a record.
Defining a structure:To define astructure, you must use thestructstatement. The struct statement defines a newdata type, with more than or equal to one member. The format of the struct statement is as follows:
struct [structure name] { member definition; member definition; ... member definition; }; (OR) struct [structure name] { member...