factorial with structures using pass by value and pass by reference

By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022

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

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials