Function Main
Declare Integer n1, n2
Output "This is a call by value add(2, 30):"
Output add(2, 3)
Output "Input first number (n1):"
Input n1
Output "Input second number(n2):"
Input n2
Output "This is a call by reference add(n1, n2):"
Output add(n1, n2)
End
Function add (Integer first, Integer second)
Declare Integer result
Assign result = first + second
Return Integer result
#include <stdio.h>
int add(int first, int second);
int main() {
int n1, n2;
printf("This is a call by value add(2, 3):\n");
printf("%d\n", add(2, 3));
printf("Input first number(n1):\n");
scanf("%d", &n1);
printf("Input second number(n2):\n");
scanf("%d", &n2);
printf("This is a call by reference add(n1, n2):\n");
printf("%d\n", add(n1, n2));
return 0;
}
int add(int first, int second) {
int result;
result = first + second;
return result;
}
I am Md. Anisur Rahman. I have completed Cyber Security for MSCSE at United International University in 2022.I have completed PGDIT from IIT, Jahangirnagar University in 2020. I'm a Head of IT at Programming24 School.
View all posts by Md. Anisur Rahman