HostGator Coupons

Saturday, February 20, 2010

Printing 1 to 10 without using a loop:::::::::

Source Code::::::
#include<stdio.h>
#include<stdlib.h>
void main()
{
static int i; // static variable is initialized to 0
i++;
if(i==11)
exit(0);
printf("%d\n",i);
main();
}

Output:::::::
1
2
3
4
5
6
7
8
9
10
-------------------------------------------------------------

Hope u enjoyed it................


No comments:

Post a Comment

free counters