Hi, I'm new in this forum and also new at programming
I'm taking a C course at college but our lecturer is quite lazy, so we need to investigate most of the stuff. Currently, I'm stuck working with an array exercise, after headdesking for a while I managed to declare and initialize one, but I've problems sorting its elements.
Exercise: creating an array of five elements as doubles, asking the user to enter values and print the sorted array.
This is what I wrote so far:
I can ask for 5 numbers stored as doubles (as asked in the problem) but I don't know how to sort the numbers. I've tried everything but without success, so I'm asking for help hereCode:#include <stdio.h> #include <stdlib.h> int main(){ double value[5]={'\0','\0','\0','\0','\0'}; /* User interaction module */ system("clear"); puts("Please enter five values:"); scanf("%lf", &value[0]); scanf("%lf", &value[1]); scanf("%lf", &value[2]); scanf("%lf", &value[3]); scanf("%lf", &value[4]); /* Printing the array */ printf("%lf, %lf, %lf, %lf, %lf \n", value[0], value[1], value[2], value[3],value[4]); return(0); }![]()



LinkBack URL
About LinkBacks




the examples I found run, but I still don't know how to adapt them to my needs.
thank you for your help!
.
and it works. 