alansam

Untitled

Oct 16th, 2020
697
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. int main() {
  4.   int array[10] = { 8, 5, 10, 15, 20, };
  5.   int pos, num, i = 4;
  6.   std::cout << "enter pos & number: ";
  7.   std::cin >> pos >> num;
  8.   while (i >= pos) {
  9.     array[i + 1] = array[i];
  10.     array[pos] = num;
  11.     i--;
  12.   }
  13.   std::cout << "number of values in array \n";
  14.   i = 0;
  15.   while (i < 6) {
  16.     std::cout << array[i++] << std::endl;
  17.   }
  18.  
  19.   return 0;
  20. }
  21.  
RAW Paste Data