Search C Program | nimishsoft@gmail.com

Number Pattern - 59

N=39714

3 9 1 7 4
9 1 7 4
1 7 4
7 4
4
#include <stdio.h>

int main()
{
    long n = 39714, i=1;
    for(i=10;i<n;i*=10);

    for (i=i/10; n>0; i/=10)
    {
        printf("%d\n", n);
        n%=i;
    }

    return 0;
}


Related Links:
- More Number Pattern Programs
- Star Pattern Programs in C
- Alphabet Pattern Programs in C
- Series Programs in C

12 comments:

  1. #include
    using namespace std;

    int drawpattern(int num[],int digits)
    {
    for (int i=0;i>n;
    int temp1=n;
    int temp2=n;
    int num[10],k,digits=0;
    while(temp1!=0)
    {
    temp1=temp1/10;
    digits++;
    }
    for(int i=0;i<digits;i++){
    k=temp2%10;
    num[digits-i-1]=k;
    temp2=temp2/10;
    }
    drawpattern(num,digits);
    return 0;
    }

    works for any number you input - Arpit

    ReplyDelete
    Replies
    1. #include
      #include
      #include

      int main(){

      int i,j,a[5]={3,9,1,7,4};

      for(i=5;i>=1;i--){
      for(j=i;j>=1;j--){
      printf("%d ",a[5-j]);
      }

      printf("\n");
      }

      }

      Delete
  2. Thanks for the program.It was helpful.

    ReplyDelete
  3. The given N is N=39714, but the printed output was N=39174 instead of N=39714

    please reply me am i understood wrong or correct?

    ReplyDelete
  4. long n = 39714;
    int k=1,l=0;
    while (n%k != n) {
    k = k * 10;
    l++;
    }
    for (int i = 1; i <=l ; i++) {
    System.out.print(n%k);
    k=k/10;
    System.out.println();
    }

    ReplyDelete
  5. it is really helpfull

    ReplyDelete
  6. #include
    int main()
    {
    int n,i,j,h;
    n=39174;
    h=10000;
    while(n!=1)
    {
    printf("%d\n",n);
    n=n%h;
    h=h/10;
    if(n==0)
    {
    break;
    }
    }
    return 0;
    }

    ReplyDelete
  7. Bro correct it it's %ld because it long integer

    ReplyDelete