-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CRUD operation on Array * CRUD operation on Array
- Loading branch information
1 parent
a168165
commit 2734df3
Showing
5 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"iostream": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: g++.exe build active file", | ||
"command": "C:\\mingw\\mingw64\\bin\\g++.exe", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}\\${fileBasenameNoExtension}.exe" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include<iostream> | ||
using namespace std; | ||
void CreateArray(int *arr,int n){ | ||
for(int i = 0;i<n;i++){ | ||
cout << "Enter Element" << i+1 << " : "; | ||
cin >> arr[i]; | ||
} | ||
|
||
} | ||
|
||
void PrintArray(int *arr,int n){ | ||
for(int i=0;i<n;i++){ | ||
cout << arr[i] << ", "; | ||
} | ||
cout << "\n"; | ||
} | ||
|
||
void UpdateElemet(int *arr,int n,int i){ | ||
if(i>=n){ | ||
cout << "Invalid Index"; | ||
return; | ||
} | ||
cout << "Enter new Element : "; | ||
cin >> arr[i]; | ||
} | ||
int DeteteElemet(int *arr,int n,int i){ | ||
for(int x = i;x<n-1;x++){ | ||
arr[x] = arr[x+1]; | ||
} | ||
return --n; | ||
} | ||
|
||
int main(){ | ||
int n; | ||
cout << "Enter the number of elements in array: "; | ||
cin >> n; | ||
int arr[n]; | ||
CreateArray(arr,n); | ||
PrintArray(arr,n); | ||
UpdateElemet(arr,n,2); | ||
PrintArray(arr,n); | ||
n = DeteteElemet(arr,n,3); | ||
PrintArray(arr,n); | ||
return 0; | ||
|
||
} |
Binary file not shown.
Binary file not shown.