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 / bitan biswas

We can do that by recursive call.....

void fun(int no ){
int t;
printf("%d ",no);
if( no != 100 ){
t=no+1;
fun(t);
}
printf("%d ",no);
}

int main(){
fun(1);
return 0;
}

Is This Answer Correct ?    17 Yes 27 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1078


Explain how can I pad a string to a known length?

661


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

782


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


Can static variables be declared in a header file?

622






What is difference between Structure and Unions?

644


The file stdio.h, what does it contain?

670


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

634


What is include directive in c?

651


What are the types of macro formats?

613


how to construct a simulator keeping the logical boolean gates in c

1732


How do I get an accurate error status return from system on ms-dos?

653


Explain modulus operator. What are the restrictions of a modulus operator?

604


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

582


Explain 'bus error'?

565