Search C Program

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

4 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