Site icon

Factorial Program with Nested Structure C++

Nested Structure Factorial C++

Factorial Program with Nested Structure C++

Let us begin with the Factorial Program with Nested Structure.

#include <iostream>
using namespace std;
struct factorial_struct1{
	int x=1;
struct factorial_struct2{
	int  n;
	factorial_struct1 obj2;
int main(){
	factorial_struct2 obj1;
	cout<<"Enter a number \n";
	for (int i=1;i<=obj1.n; i++)
	obj1. obj2.x=obj1. obj2.x * i;	
cout<<"Factorial="<<obj1. obj2.x;
return 0;}


More Practice on Factorial problem in C++

  1. Factorial Program in C++
  2. factorial using single inheritance
  3. Factorial Program in C++ using Class Objects
  4. factorial using Multiple inheritances
  5. C++ program for factorial using Constructor DestructorFactorial Of A Number By Using The Recursion
  6. Factorial Program with structures and pointers C++
  7. Factorial Program with Nested Structure C++
  8. factorial of a no. by defining the member functions outside the class
Exit mobile version