Factorial Program with Nested Structure C++
Factorial Program with Nested Structure C++
Let us begin with the Factorial Program with Nested Structure.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#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"; cin>>obj1.n; for (int i=1;i<=obj1.n; i++) { obj1. obj2.x=obj1. obj2.x * i; } cout<<"Factorial="<<obj1. obj2.x; return 0;} |
Output
More Practice on Factorial problem in C++
- Factorial Program in C++
- factorial using single inheritance
- Factorial Program in C++ using Class Objects
- factorial using Multiple inheritances
-
C++ program for factorial using Constructor DestructorFactorial Of A Number By Using The Recursion - Factorial Program with structures and pointers C++
- Factorial Program with Nested Structure C++
- factorial of a no. by defining the member functions outside the class