A pattern of numbers program – array of and within structure
A pattern of numbers program with an array of structure
C++ program to print pattern of numbers with an array of structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include<iostream> using namespace std; struct counting{ int i; int j; int k=0; }; int main() { int y; counting count[3]; for(y=0;y<1;y++){ for(count[y].i=0;count[y].i<10;count[y].i++) { for(count[y].j=1;count[y].j<count[y].i;count[y].j++) { printf("%d",count[y].k); count[y].k++; } printf("\n"); } } return 0; } |
Output
C++ program to print a pattern of numbers by using an array within the structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include<iostream> using namespace std; struct counting{ int i[3]; int j[3]; int k=0; }; int main() { int y; counting c; for(y=0;y<1;y++) { for(c.i[y]=0;c.i[y]<10;c.i[y]++) { for(c.j[y]=1;c.j[y]<c.i[y];c.j[y]++) { printf("%d",c.k); c.k++; } printf("\n"); } } return 0; } |
Output