C Program - Another nested loop issue -
just started learn nested loop logic in c programming, , don't know how achieve in c programming, length , row should follow input number, , use '-' separate data
enter number: 2 -1-3 ----  enter number: 7 -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3 -------------- -1-3-5-7-9-1-3   anyone knows how achieve it? help.
#include <stdio.h>  int main(){     int i,j,n;      printf("enter number: ");     scanf("%d", &n);     for(i=0;i<n;++i){         for(j=0;j<2*n;++j){             if(i%2==0 && j%2==1)                 printf("%d", j % 10);             else                 printf("-");         }         printf("\n");     }     return 0; }      
Comments
Post a Comment