Created
April 29, 2019 05:00
-
-
Save koetoo/9ab92d69940a399b73f4c466fa7ac53a to your computer and use it in GitHub Desktop.
ptrtrain
This file contains hidden or 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
#include <iostream> | |
const int MAX=5; | |
using namespace std; | |
void convert(double* ptr){ | |
for(int i=0;i<MAX;i++) | |
*ptr++ *=2.5; | |
} | |
int main(){ | |
double sum=0; | |
double arr[MAX]={10,20,30,50,100}; | |
convert(arr); | |
for(int i=0;i<MAX;i++){ | |
sum+=arr[i]; | |
cout<<i+1<<" "<<arr[i]<<endl; | |
} | |
double avg=0; | |
avg=sum/MAX; | |
cout<<"total is "<<sum<<endl; | |
cout<<"average is "<<avg<<endl; | |
cout<<"number 1 is "<<arr[0]<<endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment