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

Why c is called a middle level language?

634


if p is a string contained in a string?

1404


Describe the order of precedence with regards to operators in C.

631


What is difference between stdio h and conio h?

882


An instruction which is analysed and acted upon by the processor prior to the compiler going its work a) directive b) constructive c) constant d) absolute mode

603






The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

704


Is it possible to execute code even after the program exits the main() function?

809


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3689


Write a code of a general series where the next element is the sum of last k terms.

589


What's the difference between constant char *p and char * constant p?

651


What is memcpy() function?

620


Is c still used?

598


List a few unconditional control statement in c.

557


What is union and structure?

569


What is variable in c example?

590