Skip to content

resizing array and populating with double the numbers in given array

Notifications You must be signed in to change notification settings

maryam-mehr/repository3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

repository3

resizing array and populating with double the numbers in given array #include using namespace std; #define size 50 int resize(int[], int); int main() { cout << "enter size of array" << endl; int s; cin >> s; int array[size]; cout << "enter array" << endl; for (int i = 0; i < s; i++) { cin >> array[i]; } cout << "GIVEN ARRAY" << endl; for (int i = 0; i < s; i++) { cout<< array[i]; } cout << endl; resize(array, s); } //function int resize(int arr[size], int x) { int newarr[size] = { 0 }; int newsize = x * 2; for (int i = 0; i < x; i++) { newarr[i] = arr[i]; } /for (int i = 0; i < newsize; i++) { cout << newarr[i] << " "; }/ int j = 0; for (int i = x; i < newsize; i++) { newarr[i] = arr[j] * 2; j++; } cout << "RESIZED ARRAY" << endl; for (int i = 0; i < newsize; i++) { cout << newarr[i] << " "; } return 0; }

About

resizing array and populating with double the numbers in given array

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published