Write a C++ program without using any loop (if, for, while
etc) to print numbers from 1 to 100 and 100 to 1;

Answer Posted / ajeet kumar

#include<stdio.h>
#include<conio.h>

int f(int);

void main()
{
static int n=0;

n++>99 ? 0 : f(n) ; //its value are not used.
}

int f(int n)
{
printf(" %d",n);
main();
printf(" %d",n--); //]internally stack is ctr
return(1);
} /* run firstly,after press alt+F5.

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bash c?

544


Where local variables are stored in c?

544


How can type-insensitive macros be created?

684


What is the difference between scanf and fscanf?

650


What is difference between array and pointer in c?

528






Explain the concept and use of type void.

616


Can a pointer be null?

548


What is structure of c program?

589


Do you know what are the properties of union in c?

569


how is the examination pattern?

1583


What is clrscr ()?

626


Write a program in c to replace any vowel in a string with z?

676


If null and 0 are equivalent as null pointer constants, which should I use?

567


What is 1d array in c?

585


what is ur strangth & weekness

1798