In F’n declaratory (or) in f’n header, whatever the variables we are creating are called formal arguments or parameters.
Note:
Where the implementation part of the f’n is available, it is called f’n definition.
there are ‘2’ types of calling conversions are available e
{
printf(“n x=%d y=%d”, x,y);
}
void main()
{
int a;
a=10;
abc(++a,a++);
printf(“na=%d”,a);
}
o/p : x=12 y=10 a=12
{
printf(“n x=%d Y=%d”, x,y);
}
void main()
{
int a;
a=10;
xyz(a++,++a);
printf(“n%d”,a);
}
o/p : x=10; y=12 a=12;
In ‘c’ programming language there are two types of parameters passing techniques are available i.e
eg: printf(), pow(), sqrt(), cos(), delay(), text color()
eg: scanf(), strcpy(),strrev(),strupr(),settime()
{
int t;
t=1;
a=b;
b=t;
printf(“n a=%d b=%d ”,a,b);
}
void main()
{
int a,b;
a=10; b=20;
swap(a,b);
printf(“na=%d b=%d”,a,b);
}
o/p : error undefined symbol a,b
{
int t;
t=a;
a=b;
b=t;
printf(“n data in swap a=%d b=%d ”,a,b);
}
{
int a,b;
a=10, b=20;
swap(a,b);
printf(“n data in main a=%d b=%d ”,a,b);
}
o/p : data in swap a=20 b-10 data in main a=10 b=20
{
int t;
t=*p1; //t=1
*p1=*p2; //a=b
*p2=t; //b=t
printf(“n data in swap a=%d b=%d, *p1,*p2”);
}
The above program swap f’n is working with the help of call by address mechanism, that why all the modification of the swap f’n will pass back to main f’n
Note : ‘c’ programming language does not supports call by reference.
Program to Call by reference
int power(int b,int e){int r=l,i;if(e<0)
return 0;
for(i=1;i<=e;i++)
r=r*b;
return r;
}
Void main()
{
Int a,b,p;
Clrscr();
Printf(“n Enter value of a:”);
Scanf(“%d”,&a);
Printf(“n Enter value of b:”)
Scanf(“%d”, &b);
//p=pow(a,b); <math.h>
P=power(a,b);
Printf(“n %d ^ %d value is : %d”,a,b,p);
Getch();
}
O/P : enter a value of a:2
Enter the value of b:5
25 value is : 32
{
if(x>y)
return x;
else
return Y;
}
Void main()
{
int m;
m=max(10,20);
printf(“n max value is %d”,m);
}
o/p : max value is =20
{
int a=10,b=20,c=30;
a*=10+2; //a=a*(10+2);
b%=6; //b=b%6;
c/3; //c=c/3;
*p1=b; //j=b;
*p2=c //k=c;
return a;
}
void main()
{
int i,j,k;
i=abc(&j,&k);
printf(“ni=%d j=%d k=%d”,i,j.k);
getch();
}
o/p : i=20; j=2; k=10 Enter a value =5 5 fact value is =120
{
int n,f;
// int fact(int); declaration
clrscr();
printf(“Enter a value”);
scanf(“%d”,&n);
f=fct(n);
printf(“n %d fact value is : %d”,n,f);
getch();
}
int fact (int n)
{
int r=1,i;
for(“i=n,i>=1;i--”);
r=r*i;
return r;
According to K and RC standard above prog is valid because whenever the f’n return type is an integer parameter type is other than float then doesn’t require to go for forwarding declaration.
According to ANSI-C standard, the above program is an error because the forward declaration of a f’n must be required whenever we are defining a f’n after calling.
You liked the article?
Like: 0
Vote for difficulty
Current difficulty (Avg): Medium
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.