How to Nest two Structure? C++ Program.
This program covers the following concepts;
- structure
- nested structures
- user define function(function definition, declaration and calling)
- nested for loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include<iostream> using namespace std; struct counting { int i; int j; int k=0; }; struct counting1{ int c; counting c1; }; int main(){ counting1 c2; for(c2.c1.i=0;c2.c1.i<=10;c2.c1.i++){ for(c2.c1.j=1;c2.c1.j<c2.c1.i;c2.c1.j++){ printf("%d",c2.c1.k); c2.c1.k++; } printf("\n"); } return 0; } |
Output