/*
Write a program using pointers to input any number
and then pass that number to the function which will
increment the value pointed by that pointer by 1
*/
#include<iostream.h>
void increment(int* p); // function declaration
int main(){
int a;
int* p=&a; // declaring pointer p and intializing it to address of integer a
cout << " Enter a number: ";
cin >> a;
cout << endl << "You have enetered: " << a << endl;
increment(p);
cout << endl << "Value after incrementing is: " << a << endl;
// Another way to call for function is to send the address like below
increment(&a);
cout << endl << "Value after second increment is: " << a << endl;
return 0;
} // end main()
// ========= increment() ================
void increment(int* p1){
(*p1)++;
return;
} // end increment()
Write a program using pointers to input any number
and then pass that number to the function which will
increment the value pointed by that pointer by 1
*/
#include<iostream.h>
void increment(int* p); // function declaration
int main(){
int a;
int* p=&a; // declaring pointer p and intializing it to address of integer a
cout << " Enter a number: ";
cin >> a;
cout << endl << "You have enetered: " << a << endl;
increment(p);
cout << endl << "Value after incrementing is: " << a << endl;
// Another way to call for function is to send the address like below
increment(&a);
cout << endl << "Value after second increment is: " << a << endl;
return 0;
} // end main()
// ========= increment() ================
void increment(int* p1){
(*p1)++;
return;
} // end increment()