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

Hai what is the different types of versions and their differences

1755


Explain what are linked list?

837


What is the purpose of void pointer?

833


What is the acronym for ansi?

842


struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer

1065


Is Exception handling possible in c language?

1825


Why can’t we compare structures?

1073


What is line in c preprocessor?

845


Why is c platform dependent?

836


Why can arithmetic operations not be performed on void pointers?

843


Explain the use of bit fieild.

947


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

2686


What is a const pointer in c?

904


What do you mean by scope of a variable in c?

804


What is s or c?

821