+ 1
#include <iostream> #include <chrono> using namespace std; using namespace std::chrono; int main() { int arr1[10], i, j, temp;
Code to find array of 10 elements in increasing order Help me check why 0 repeats itself after execution
4 Antworten
+ 4
can you please show us your attempt so that we can see what you have done so we can help you...
Thanks
+ 2
ivy jepkirui, there's nothing to check, you haven't written anything yet. 🤔
+ 2
#include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main() {
int arr1[10], i, j, temp;
auto start = high_resolution_clock::now();
cout<<"Enter number;"<<endl;
for(i=0;i<=10; i++)
{
cin>>arr1[i];
}
for(i=0; i<10;i++)
{
for(j=0;j<10-i; j++)
{
if(arr1 [j]>arr1 [j+1])
{
temp=arr1[j];
arr1[j]=arr1[j+1];
arr1[j+1]=temp;
}
}
}
cout<<"sorted data"<<endl;
for(i=0;i<10;i++)
{
cout<<arr1[i]<<""<<endl;
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop-start);
cout<<"Time taken:"<<duration.count()<<"microseconds"<<endl;
return 0;
}
0
Check the code