Untitled
unknown
c_cpp
2 years ago
922 B
6
Indexable
#include <iostream> #include <fstream> #include <string> using namespace std; int arr[5]; int i = -1; void input() { i++; cout << "enter value" << endl; cin >> arr[i]; } void read() { for (int j = 0; j <= i; j++) { cout << arr[j] << endl; } } void del() { int x; cout << "which index do you want to delete?" << endl; cin >> x; for (int j = x; j < i; j++) { arr[j] = arr[j + 1]; } arr[i] = 0; i--; } int main() { int choice; char cont; do { system("cls"); cout << "press 1 to input, press 2 to delete, press 3 to print all values" << endl; cin >> choice; if (choice == 1) { input(); } else if (choice == 2) { del(); } else if(choice == 3) { cout << "\n \n"; cout << "values are: \n"; read(); } cout << "do you want to continue? y /n"; cin >> cont; } while(cont == 'y'); return 0; }
Editor is loading...