Please help to find the error my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Please help to find the error my code

The concept of the code is: 1.Ask the user to enter a group of elements of the array 2.ask the user to choose wich order he wants to sort the array 3.ask the user to enter an element in order to search it the array (Found or not found) https://code.sololearn.com/chpEJP73rzEE/?ref=app

19th Feb 2020, 4:51 PM
Amal Gil
Amal Gil - avatar
31 Answers
- 2
The biggest problem is that you did not assign any initial values ​​to the following variables : d, g, premier, dernier, even though you used them in functions. I think you mean by premier the first and by dernier the last so, you have to add this two line befor using them : premier = 0; dernier = n-1; i don't know what d, g need for, but you have to assign them initial values. in line 104 remove return, and add return 0; at the end of code.
19th Feb 2020, 10:14 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
+ 3
In lines 80 and 81. Make it lecture(t, x); and affichage(t, x); n has no value there.
19th Feb 2020, 8:15 PM
Paul
Paul - avatar
+ 1
Why are t and n arguments for these functions? n doesn't have an value yet. x has a value, but you aren't using it. lecture(t,n);//calling the function in order to enter the elements of the array affichage(t,n);//printing them
19th Feb 2020, 6:13 PM
Paul
Paul - avatar
+ 1
Yes indeed.
19th Feb 2020, 11:21 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
21st Feb 2020, 5:11 AM
naresh
naresh - avatar
+ 1
Thank so much rafik for your effort
22nd Feb 2020, 12:02 AM
Amal Gil
Amal Gil - avatar
0
t it is an array ,and n it is the size #for(i=0;i<n;i++) Scanf("%d",&t[i])
19th Feb 2020, 7:36 PM
Amal Gil
Amal Gil - avatar
0
I did not understand what do you mean
19th Feb 2020, 7:36 PM
Amal Gil
Amal Gil - avatar
0
Salam, 1st use pointer *t instead of t[] in each function parameter.
19th Feb 2020, 8:32 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
2nd, line 79 you wrote this : scanf("%d", &x); lecture(t, n); Changr x by n : scanf("%d", &n);
19th Feb 2020, 9:17 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
i=g and j=d
19th Feb 2020, 10:26 PM
Amal Gil
Amal Gil - avatar
0
yes i see that inside the function, but in main() function, g = ? And d = ?.
19th Feb 2020, 10:28 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
Why please is it necessary
19th Feb 2020, 10:29 PM
Amal Gil
Amal Gil - avatar
0
You used d and g as tri_croissant_rapid function parameters, tri_croissant_rappide(t,n,g,d); in line 91 but g and d have no value, how the function will use them?
19th Feb 2020, 10:33 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
What do you mean by d and g? what's their role in the code?
19th Feb 2020, 10:36 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
Gauche for g and droite for d Quick sort method in ascending order I can also use low and high
19th Feb 2020, 10:44 PM
Amal Gil
Amal Gil - avatar
0
Usually، use 0 for the low value, and n-1 (array.size() -1) for the hight value.
19th Feb 2020, 11:13 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar
0
In the main function ??
19th Feb 2020, 11:19 PM
Amal Gil
Amal Gil - avatar
0
Okay thank you so much for your help
19th Feb 2020, 11:22 PM
Amal Gil
Amal Gil - avatar
0
U r welcome.
19th Feb 2020, 11:22 PM
Rafik Abdelhak Nadir
Rafik Abdelhak Nadir - avatar