1 Replies - 186 Views - Last Post: 16 February 2019 - 01:34 AM Rate Topic: -----

#1 simonmak   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 04-February 19

To print the pattern in C

Posted 16 February 2019 - 01:32 AM

How to print the pattern as follows?

#1234567
1#345678
23#56789
345#7890
4567#901
56789#12
678901#3
7890123#

int main() {
    int pattern;
    int rows, columns;

    printf("Enter the pattern: ");
    scanf("%d", &pattern);

    for (rows=1; rows<=pattern; rows++) {
        for (columns=1; columns<=pattern; columns++) {
            if(rows==columns)
                printf("#");
            else
		printf("%d",columns);
		}
        printf("\n");
    }

    return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: To print the pattern in C

#2 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,837
  • Joined: 13-June 14

Re: To print the pattern in C

Posted 16 February 2019 - 01:34 AM

Is there something wrong with the code you posted? If there are errors, what are they and what do you think they are telling you? If the program doesn't work correctly, what is the problem and what have you done to debug it?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1