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 shabbir; 4Sep2009 at 22:12.. Reason: Code blocks