Write down the program to sort the array.

Answer Posted / anon

#include <stdio.h>

int main() {
int i, j, size, values[100], temp;

printf("Enter the size of an array: ");
scanf("%d",&size);
printf("Enter the values of array: ");
for(i=0;i<size;i++){
scanf("%d",&values[i]);
}

for(i=0;i<size-1;i++){
for(j=i+1;j<size;j++){
if(values[i]<values[j]){
temp=values[i];
values[i]=values[j];
values[j]=temp;
}
}
}
printf("Sorted array:
");
for(i=0;i<size;i++){
printf("%d ",values[i]);
}

return 0;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you list files in a directory?

837


What is the difference between array and pointer?

797


Differentiate between the = symbol and == symbol?

952


What are the parts of c program?

870


what is the difference between class and unio?

2127


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

1187


What is a c token and types of c tokens?

834


Is array name a pointer?

836


Can we use any name in place of argv and argc as command line arguments?

840


What is && in c programming?

924


What standard functions are available to manipulate strings?

844


to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?

1855


Explain built-in function?

874


Is c# a good language?

808


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

937