Guest User

Untitled

a guest
Apr 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int SIZE=50;
  5.  
  6. void main()
  7. {
  8. int arr[SIZE],i,j,input,counter2=0,index,temp_counter,temp_index;
  9.  
  10. cout<<"please enter natural numbers";
  11. i=0;
  12. do
  13. {
  14. cin>>input;
  15. }
  16. while (input != -1)
  17. {
  18. arr[i]=input;
  19. i++;
  20. }
  21.  
  22. for (j=0; j<i; j++)
  23. {
  24. if (arr[j]>=arr[j+1])
  25. {
  26. counter2++;
  27. index=j;
  28. }
  29. temp_counter=counter2;
  30. temp_index=index;
  31. }
  32.  
  33. cout<<"the index is" << temp_index<< endl;
  34. }
Add Comment
Please, Sign In to add comment