Professional Documents
Culture Documents
More On Functions: Prof. Debashis Hati
More On Functions: Prof. Debashis Hati
return 0;
}
void check_even_odd(int x){
}
1.WAP to implement a function check_even_odd(int
x) to find the integer is even or odd.
int main(){
int no;
void check_even_odd(int z);
printf(‘’Enter number”);
scanf(“%d”,&no);
check_even_odd(no)
return 0;
}
void check_even_odd(int x){
int remainder= x%2;
if (remainnder==0)
printf(“even”);
else
printf(“odd”);
}
1.WAP to implement a function check_even_odd(int
x) to find the integer is even or odd.
int main(){
int no,x;
int check_even_odd(int z);
printf(‘’Enter number”);
scanf(“%d”,&no);
x=check_even_odd(no)
if (x==0)
printf(“even”);
else
printf(“odd”);
return 0;
}
int check_even_odd(int x){
int remainder= x%2;
if (remainnder==0)
return 0;
else
return 1;
}
1.WAP to implement a function check_even_odd(int
x) to find the integer is even or odd.
int main(){
int no,x;
int check_even_odd(int z);
printf(‘’Enter number”);
scanf(“%d”,&no);
x=check_even_odd(no)
if (x==0)
printf(“even”);
else
printf(“odd”);
return 0;
}
int check_even_odd(int x){
int remainder= x%2;
if (remainnder==0)
return 0;
else
return 1;
}
2.WAP to implement a function min(int x,int y) to
find the smallest of two integers.
3.WAP to implement a function min(int x,int y,int z)
to find the smallest of three integers.
4.WAP to implement a function min(int x,int y) to
find the smallest of four integers.
Assignment-18,16/12/21
1.WAP to implement a function void
check_even_odd(int x) to find the integer is even
or odd.
WAP to implement a function int
check_even_odd(int x) to find the integer is even
or odd.
2. int min(int,int);
3.int min(int,int,int);
4. Smallest among 4 integers using int min(int,int);
5. int power( int,int)
Parameter Passing
The mechanism to pass the information
from function call to function definition is
called parameter passing.
It is of two types
1.Call by value
2.Call by reference
Call by value
The value of arguments is copied /
transferred /passed to the formal
parameters.
int main(){ void f1(int y){
int x; y=y*2;
}
void f1(int z);
return 0;
}
Call by value
The value of arguments is copied /
transferred /passed to the formal
parameters.
int main(){ void f1(int y){
int x; y=y*2;
}
void f1(int z);
f1(x);
}
Call by value
The value of arguments is copied /
transferred /passed to the formal
parameters.
int main(){ void f1(int y){
int x; y=y*2;
}
void f1(int z);
f1(x);