1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Generation of lucky numbers out of given set of nos

Discussion in 'C' started by amanbaua, Sep 4, 2009.

Thread Status:
Not open for further replies.
  1. amanbaua

    amanbaua New Member

    Joined:
    Aug 23, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    /*THE LOGIC BEHIND THIS PROGRAM IS THAT SUPPOSE THERE IS A SET OF NOS
    1 2 3 4 5 6 7 8 9 10
    FIRST EVERY 2ND NO IS DELETED WE GET
    1 3 5 7 9
    THEN EVERY 3RD NO IS DELETED
    1 3 7 9
    THEN EVERY 4TH NO IS DELETED
    1 3 7
    THEN EVERY 5TH NO IS DELETED
    AS THER IS NO 5TH NO SO THE LUCKY NOS ARE
    1 3 7*/
    #include"stdio.h"
    #include"conio.h"
    void main()
    {
      int i,k=0,p=2,t=0,n;int a[100];
      printf("enter the size of the array:\n");
      scanf("%d",&n);
      printf("enter the elements of the array\n");
      for(i=0;i<n;i++)
      {
        scanf("%d",&a[i]);
      }
      printf(" The Sequence Of Lucky Nos Per Step Are:\n");
      for(i=0;i<n;i++)
      {
         printf("%d",a[i]);
         printf("\t");
      }
    
      while(1)
      {
         t=0;
        for(i=0;i<n;i++)
      {
    
         if(a[i]!=32767)
         {
            k++;
            if(k==p)
            {
              a[i]=32767;t++;
              k=0;
            }
    
          }
        }
            p++;k=0;
             if(t==0)
             {
                  break;
             }
             printf("\n");
                for(i=0;i<n;i++)
            {
                if(a[i]!=32767)
              {
             printf("%d ",a[i]);
             printf("\t");
              }
            }
             printf("\n");
    
    
    
        }
         getch();
     }
     
    Last edited by a moderator: Sep 4, 2009
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Duplicate of http://www.go4expert.com/showthread.php?t=19295
    Unless the code is different, I haven't checked for that.
    Posting duplicate threads is a good way to get banned; please don't do that (unless getting banned is your aim of course).
     
  3. amanbaua

    amanbaua New Member

    Joined:
    Aug 23, 2009
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    hey mr mentor both i mean 2 say both the article and the thread r posted by me
    its d same amanbaua
    understand
     
  4. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,343
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    :rofl: :rofl:

    The last one you posted was transferred to the queries forum, it's not an article.
    And, I think xpi0t0s perfectly understands the facts that :
    (1) both are the same.
    (2) both are posted by you.

    ======

    Duplicate of http://www.go4expert.com/showthread.php?t=19295.

    [[ Thread CLOSED ]]
     
Thread Status:
Not open for further replies.

Share This Page