In: Computer Science
Write a function treble that takes a pointer to an integer and
triples its value. Note that this function does not return
anything. You can test it using the following example or something
similar:
int i=7;
cout << "old value; i="<<i<< "-"
treble(&i);cout <<"New Value:i="<< i
<<"\n";
Which prints: Old vvalue:i =7 - new value: i=21
#include <iostream>
using namespace std;
void treble(int *ptr){
*ptr = 21;
}
int main() {
int i=7;
cout << "old value; i="<<i<< "-";
treble(&i);
cout <<"New Value:i="<< i <<"\n";
//Which prints: Old vvalue:i =7 - new value: i=21
}
=====================================
SEE OUTPUT
PLEASE COMMENT if there is any concern.
==============================