C Loop Patterns -


i've got code half way working can't other half work.

what pattern needs like:

1sssss
s2ssss
ss3sss
sss4ss
ssss5s
sssss6

what pattern looks like:

1
s2
ss3
sss4
ssss5
sssss6

here code

#include <stdio.h> int main() {     int i, j, k, num;      printf("enter number ");     scanf("%d", &num);      (i = 1; <= num; ++i)     {         (j = 1; j <= i; ++j)         {             if (j != i) {                 printf("s");             }         }          printf("%d ", j-1);         printf("\n");     }      return 0; } 

i guess made mistake in one.

     for(int j=1; j<=i ; ++j) 

i should until num variable, because need print num times.

hope helps


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -