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

How can I prevent another program from modifying part of a file that I am modifying?

618


Explain setjmp()?

663


Define the scope of static variables.

610


Explain what is a pragma?

596


What does c value mean?

637






what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?

1458


Can a file other than a .h file be included with #include?

690


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1323


What is data structure in c and its types?

601


What is the full form of getch?

591


what are non standard function in c

1443


Apart from dennis ritchie who the other person who contributed in design of c language.

819


Write a code to determine the total number of stops an elevator would take to serve N number of people.

737


How can I copy just a portion of a string?

822


What is a void * in c?

602