MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / main

Function main

Lab_08/inserting.cpp:4–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2using namespace std;
3
4int main()
5{
6 int a[15], value, i, pos;
7 int size = 10;
8 cout << "Enter array elements: ";
9 for (i = 0; i < 10; i++) // input the array elements
10 {
11 cout << "a[ " << i << " ] = ";
12 cin >> a[i];
13 }
14 // code for asking the value and the position to be inserted
15 cout << "Enter element to be insert : ";
16 cin >> value;
17 cout << "At which position: ";
18 cin >> pos;
19 // changing the place of arrays
20 for (i = 10; i > pos; i--)
21 {
22 a[i] = a[i - 1];
23 }
24 a[pos] = value;
25 // outputing correct araays order
26 for (i = 0; i < size + 1; i++)
27 {
28 cout << a[i] << " ";
29 }
30 system("pause");
31 return 0;
32}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected