+ 1

Hello everyone.I really need help to answer this please. Please help me. I need to create an array using c++. Condition below:

Program 1: ❑ Search for the smallest value in the array ❑ Place this value in a[0], and place the value that was in a[0] in the location where the smallest was found ❑ Starting at a[1], find the smallest remaining value swap it with the value currently in a[1] ❑ Starting at a[2], continue the process until the array is sorted

6th Jun 2022, 9:33 AM
Bismarckxf
Bismarckxf - avatar
15 Antworten
+ 1
Right but..... We aren't going times do the work for you. If there's something specific you don't understand about the instructions then state that or if you're running into a bug, send your code attempt. Other than that, you need to try on your own. Start with making some pseudocode of your own by breaking down the instructions into even smaller problems and try from there.
6th Jun 2022, 9:48 AM
Justice
Justice - avatar
+ 1
That's okay, but it looks like you're not doing the last bullet points of the criteria. Are you sure that you're focusing on sorting the entire array or just printing the smallest value? There's a big difference.
6th Jun 2022, 10:44 AM
Justice
Justice - avatar
+ 1
It's a selection sort. Refer here. https://www.softwaretestinghelp.com/selection-sort/
7th Jun 2022, 4:25 PM
Akang Toshi
Akang Toshi - avatar
0
Where's your attempt?
6th Jun 2022, 9:36 AM
Justice
Justice - avatar
0
Juby Neil Cisneros Valiao What do you mean by that? They literally gave you some good instructions. It's almost pseudocode.
6th Jun 2022, 9:43 AM
Justice
Justice - avatar
0
You're right it's almost a pseudocode. Well, that's what they gave us...
6th Jun 2022, 9:46 AM
Bismarckxf
Bismarckxf - avatar
0
I'll be back with a code... thank you
6th Jun 2022, 9:50 AM
Bismarckxf
Bismarckxf - avatar
0
Mr. Justice Is this Right? I think I got it #include<iostream> using namespace std; int main(){ int x[]={9,8,7,6,5,4,3,2,1,}; int len = sizeof(x) / sizeof(x[0]); if (len>0){ int smallest = x[0]; for (int i=1; i<len; i++ ) { if (smallest>x[i] ){smallest = x[i]; } } cout << "Smallest Value : " << smallest <<endl; } else { cout << "No elements in the array." <<endl; } }
6th Jun 2022, 10:38 AM
Bismarckxf
Bismarckxf - avatar
0
I am a woman and have you checked to see if you're getting the right output? You can test it by pasting your code in the Code Playground.
6th Jun 2022, 10:39 AM
Justice
Justice - avatar
0
I'm sorry ma'am... I stand corrected. Yes, I did and I think it is running well
6th Jun 2022, 10:42 AM
Bismarckxf
Bismarckxf - avatar
0
I also want to sort the entire array ma'am. How do I do that?
6th Jun 2022, 10:45 AM
Bismarckxf
Bismarckxf - avatar
0
The instructions your teacher gave is telling you so I don't think there's a need to restate it. Make sure you read what they're saying carefully. You can watch this video to help picture it as well: https://youtu.be/3hH8kTHFw2A
6th Jun 2022, 10:50 AM
Justice
Justice - avatar
0
I am new to coding so i have a question: When i use elif after using else, i got a synthx error: Why is it? Can’t this elif be related to the if before?
7th Jun 2022, 2:08 AM
Win Thein
0
If i was you am gonna try it myself if it get right is okay, and if it didn't get right it's also okay. Then i should take a screenshot and send it then ask who can show me the right way to perform it not to do it for me at all. Sorry if my words is hurt!
7th Jun 2022, 5:20 PM
Muhammad Bello
Muhammad Bello - avatar
- 1
To be honest, I haven't attempted once. I really don't know how. My teacher just gave the condition to us without telling us how.
6th Jun 2022, 9:39 AM
Bismarckxf
Bismarckxf - avatar