+ 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
16 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.
+ 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.
+ 1
It's a selection sort.
Refer here.
https://www.softwaretestinghelp.com/selection-sort/
0
Where's your attempt?
0
Juby Neil Cisneros Valiao What do you mean by that? They literally gave you some good instructions. It's almost pseudocode.
0
You're right it's almost a pseudocode. Well, that's what they gave us...
0
I'll be back with a code... thank you
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;
}
}
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.
0
I'm sorry ma'am... I stand corrected.
Yes, I did and I think it is running well
0
I also want to sort the entire array ma'am. How do I do that?
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
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?
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!
- 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.