Announcement:

This is just the beginning of this blog, please don't copy any of my posts.

Sunday 8 September 2013

Function with Parameters and return Value in C programming

In C++, a parameter can be passed by:

  1. value,
  2. reference, or
  3. const-reference

Each parameter's mode is determined by the way it is specified in the function's header (the mode is the same for all calls to the function). 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.

Value Parameters

When a parameter is passed by value, a copy of the parameter is made. Therefore, changes made to the formal parameter by the called function have no effect on the corresponding actual parameter.
Program

#include<stdio.h>
#include<conio.h>
void main()
{
float r ,a;
float cir(float);
clrscr();
printf("Enter the Radius=\n");
scanf("%f",&r);
a=cir(r);
printf("\nThe area is %f",a);
getch();
}
float cir(float p)
{
return(3.142*p*p);
}

Output :
Enter The Radius
4
The Area =50.240002
Share it Please

Pankaj Gaikar

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

Copyright @ 2013 Pune University Bachelor of Engineering . Designed by Pankaj Gaikar | Love for The Tricks Machine