Wednesday, December 31, 2014

WAP to print natural numbers without using loop.

/*C program to print n natural numbers without using any loop*/
#include <stdio.h>
#include <conio.h>
void main()
{
int n, c = 1;
printf("Enter a number to End=");
scanf("%d", &n);   // Value of n should be >= 1
print:             // label
printf("%d\n", c);
c++;
if (c <= n)
goto print;
getch();
}

Expected Output:
Enter a number to End=10
1
2
3
4
5
6
7
8
9
10