# Solve this program

 Fayazur Rahman Summit · April 16, 2015 Write a nested loop to print: /*In each pass you must print only one digit */2 2 24 4 4 4 46 6 6 6 6 6 68 8 8 8 8 8 8 8 80 0 0 0 0 0 0 0 0 0 02 2 2 2 2 2 2 2 2 2 2 2 2

## Replies

 Fayazur Rahman Summit · April 21, 2015 ``#include #include int main(){    int i, j;    for(i=1; i`` Fayazur Rahman Summit · April 21, 2015 ohhat last i solve this problem #include #include int main(){    int i, j;    for(i=1; i<=6; i++){        for(j=i; j<=3*i; j++){            printf("%d", (i%5)*2);        }        printf("\n");    }    return 0;} Sharon Fabin · April 17, 2015  just make the first loop as much times as you're requested to and each time it comes to the next iteration, make a variable that will store the num of digits that need to be in the next line and another that will change the digit that is going to printed.i dont know how to write it in C but i know C++ so:``#include using namespace std;int main(){ int numOfRows,numOfCols=3,digit=2; cout << "Enter number of rows"; cin >> numOfRows; for (int i = 0; i < numOfRows; i++){ for (int j = 0; j < numOfCols; j++){ cout << digit; } if (digit == 8) digit = 0; else digit += 2; numOfCols += 2; cout << "\n"; }}`` Dol Lod · April 16, 2015 I would use an iteration counter to print a particular number to screen and update it every time. I don't know enough about the problem for other suggestions.
• 1

## C

131,163 followers