In C++, a parameter can be passed by:
For example:
void f( int a, int &b, const int &c );
Parameter a is a value parameter, b is a reference parameter, and c is a const-reference parameter.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
float n;
void cir(float);
clrscr();
puts("enter the radius");
scanf("%f",&n);
cir(n);
getch();
}
void cir(float p)
{
float res;
res=3.14*p*p;
printf("The area is =%f",res);
}
Output:
Enter The Radius
4
The area is =113.040001
- value,
- reference, or
- const-reference
For example:
void f( int a, int &b, const int &c );
Parameter a is a value parameter, b is a reference parameter, and c is a const-reference parameter.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
float n;
void cir(float);
clrscr();
puts("enter the radius");
scanf("%f",&n);
cir(n);
getch();
}
void cir(float p)
{
float res;
res=3.14*p*p;
printf("The area is =%f",res);
}
Output:
Enter The Radius
4
The area is =113.040001
Pankaj Gaikar is a
professional blogger
from Pune, India who writes on Technology, Android,
Gadgets, social media and latest tech updates at
Punk Tech
,
Being Android
&
Shake The Tech
. Email me
HERE
0 comments :
Post a Comment