Here I gave the solution to print up to 50.
if u want to make this program to print N integers you have to initialize the array Numbers with 1 to 32767.
#include <stdio.h>
#include<string.h>
void main()
{
int Input;
char Numbers[ ] = {"1\n2\n3\n4\n5\n6\n7\n\8\n\9\n10\n11\n12\n13\n
14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n
25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n
37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n
50\n"};
char Last_Num[5],*Find_Loc;
puts("Enter the Last Number");
scanf("%d",&Input);
sprintf(Last_Num, "%d", Input);
Find_Loc = strstr(Numbers, Last_Num);
*(Find_Loc + strlen(Last_Num) + 1) = '\0';
fputs(Numbers, stdout);
}