To Print 1 -10 natural numbers without using ‘ ; ‘(semi colon)

By | August 7, 2018

METHOD 1

RECURSIVE

#include<stdio.h>
#define N 10

#define num 1

int main(int num)
{
if (num <= N && printf(“%d “, num) && main(num + 1))
{
}
}

INPUT:

OUTPUT :

1 2 3 4 5 6 7 8 9 10

 

METHOD 2:

ITERATIVE

 

#include<stdio.h>

#define N 10

#define num 1

int main(int num)

{
while(num<=N && printf(“%d  “,num++){}

}

INPUT:

OUTPUT:

1 2 3 4 5 6 7 8 9 10

Leave a Reply

Your email address will not be published. Required fields are marked *