printf("How many do you want to display:");
printf("\nThe number %d:%d",i,&k);
You have a loop inside a loop. That means that, for a single value of i, you will loop over 30 values of k. Then for the next value of i, you loop another 30 times over the inner loop. I don't think that's what you want to do. Try thinking more clearly about the logic, before turning it into C++ code.