Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Elements of an array converted to absolute values by using recursion

# Elements of an array converted to absolute values by using recursion

Ratings: (0)|Views: 145|Likes:
answer to reinforcement 4.3 about converting elements of an array into absolute value using recursion!
answer to reinforcement 4.3 about converting elements of an array into absolute value using recursion!

### Availability:

See more
See less

10/02/2013

pdf

text

original

/*Reinforcement 4.3give an algorithm that uses tail recursion to convert every element inan integer array A into its absolute vale.*/#include <iostream>#include <cmath>using namespacestd; intabsolute(intArr[],intsize)// the function {if(size < 0)return0;else{if(Arr[size-1] < 0){Arr[size-1] = abs(Arr[size-1]);absolute(Arr,size-1);}}}intmain()//driver programme{int* Array;intsize;cout <<"how many values "<< endl;cin >> size;Array =new int[size]; intval;cout <<"please input the values "<< endl;for(inti =0; i< size; i++) {cin >> val;Array[i]= val;}absolute(Array,size);