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

What is the value of a[3] if integer a[] = {5,4,3,2,1}?

880


Why doesn't C support function overloading?

2183


What is the difference between malloc() and calloc() function in c language?

835


What do you mean by keywords in c?

895


What is action and transformation in spark?

847


Can a variable be both static and volatile in c?

812


Does c have circular shift operators?

976


What are the various types of control structures in programming?

818


Explain the advantages of using macro in c language?

776


Create a simple code fragment that will swap the values of two variables num1 and num2.

1060


How do I use void main?

856


What is volatile c?

782


What is the use of function in c?

935


What is a sequential access file?

878


can we change the default calling convention in c if yes than how.........?

2300