factorial with structures using pass by value and pass by reference

factorial with structures using pass by value and pass by reference.

Source code of factorial with structures in C++  by using pass by value

Following concepts are used in this program

  • structure = For example “factorial”.
  • Pass by value= For example “display(f); | void display( factorial fact )”.
  • for loop = For example “for(int i=1;i<=f.num;i++)”
Output

factorial of a number 6 is 720

Source code of factorial with structures in C++  by using pass by reference

Following concepts are used in this program

  • structure = For example “factorial”.
  • Pass by reference= For example “display(&f); | void display(struct factorial *fact )”.
  • for loop = For example “for(int i=1;i<=f.num;i++)”.
Output

Display Result

factorial of a number 5 is 120