Initialize an integer array of size 10; pass it to a function ‘arrIncrement’ using a pointer. The function should increment all elements of the array by one. Then display the updated array on screen.Give me code of this in c++
1
Expert's answer
2018-02-09T06:18:59-0500
#include <iostream> #include <stdlib.h> #include <ctime> using namespace std; void arrGenerate(int *a, int size) { srand(time(0)); for (int i = 0; i < size; i++) a[i] = rand() % 100; } void arrPrint(int *a, int size) { for(int i=0; i<size; i++) { cout<<a[i]<<' '; } cout<<endl; } void arrIncrement(int *a, int size) { for(int i=0; i<size; i++) { a[i]++; } } int main(int argc, char** argv) { const int N=10; int arr[N]; arrGenerate(arr, N); arrPrint(arr, N); arrIncrement(arr, N); arrPrint(arr, N); return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment