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

Who invented b language?

1136


Explain Function Pointer?

884


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1795


What are integer variable, floating-point variable and character variable?

859


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

833


What is meant by type casting?

823


What is the main difference between calloc () and malloc ()?

832


Is there a way to compare two structure variables?

839


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the maximum number of concurrent threads that the InnoDB plug-in can create.

1702


What is getch() function?

827


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2101


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

909


Is c compiled or interpreted?

883


What is the difference between call by value and call by reference in c?

880


What is exit() function?

748