recent

c program to print given number pattern

Write a c program to print given number pattern
46789
6789
789
89
9

#include <stdio.h>

int main()
{
    long n=46789,j=1;
    for(j=10;j<n;j*=10);

    for (j=j/10; n>0; j/=10)
    {
        printf("%d\n", n);
        n%=j;
    }
}
Powered by Blogger.