Simple Example Program for Area Of Circle Using Pointer In C++
On this page (5sections)
About this program
This is an example program in c pointer example programs. Read the concept first: Pointer Example Program in C++, then study the code and output below.
Syntax
//Function - Pass By Reference
void fn_name(int *var1,int *var2)
{
// Code
}
//Main Code- Pass By Reference
fn_name(&orginal_var1,&orginal_var2);
Simple Example Program for Area Of Circle Using Pointer
/*##Simple Example Program for Area Of Circle Using Pointer In C++*/
/*##Simple Area Of Circle C++ Program,pointers Example C++ Programming*/
/*##Pass By Reference C++ Function Example Program In C++ Programming*/
// Header Files
#include <iostream>
#include<conio.h>
using namespace std;
// Declare Area of Circle Function Using Pointer
void area_of_circle(float *value, float *result) {
*result = 3.14 * (*value) * (*value);
}
int main() {
float radius, area;
cout << "Pointer Example C++ Program : Area Of Circle Using Pointer and Functions\n";
cout << "\nEnter the radius of Circle : ";
cin>>radius;
//area = 3.14 * radius * radius;
area_of_circle(&radius, &area);
cout << "\nArea of Circle : " << area;
getch();
return 0;
}
Sample Output
Pointer Example C++ Program : Area Of Circle Using Pointer and Functions
Enter the radius of Circle : 5
Area of Circle : 78.5
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- Pointer Example Program in C++ — Concept — pointers, addresses and dereferencing in C++.
- Simple Program for Print address of Variable Using Pointer in C++ — More in c pointer example programs.
- Pointer Simple Example Program with Reference operator (&) and Dereference operator (*) — More in c pointer example programs.