I am trying to multiply array elements with 5 but I am getting the error of core dumped and if not, then, it only multiplies 5 with first element.
Here the code:
#include <iostream>
using namespace std;
int ptr_multiply(int[],int);
int main(){
int size;
cout<<"Enter the size of an array ==";
cin>>size;
int arr[size];
cout<<"Enter the elements of array ==";
for (int i=0;i<size;i++){
cin>>arr[i];
}
ptr_multiply(arr,size);
}
int ptr_multiply(int a1[],int s1){
int *ptr;
for (int i=0;s1;i++)
{
*ptr=a1[i];
ptr*=5;
cout<<"The Elements"<<" "<< i <<" "<<" after multiplying 5 is =="<<*ptr;
}}