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(); }
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).
hey mr mentor both i mean 2 say both the article and the thread r posted by me its d same amanbaua understand
: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 ]]