+ 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

2nd Feb 2020, 7:01 PM
ivy jepkirui
4 Réponses
+ 4
can you please show us your attempt so that we can see what you have done so we can help you... Thanks
2nd Feb 2020, 7:05 PM
BroFar
BroFar - avatar
+ 2
ivy jepkirui, there's nothing to check, you haven't written anything yet. 🤔
2nd Feb 2020, 7:16 PM
HonFu
HonFu - avatar
+ 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; }
2nd Feb 2020, 7:17 PM
ivy jepkirui
0
Check the code
2nd Feb 2020, 7:12 PM
ivy jepkirui