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 / sandy

#include<iostream>
int i;
class A
{
public:
A(){cout<<i++<<endl;}
~A(){cout<<--i<<endl;}
}
int main()
{
A a[100];
return 0;
}

Is This Answer Correct ?    41 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can a number be converted to a string?

600


Multiply an Integer Number by 2 Without Using Multiplication Operator

318


Does c have enums?

600


What is calloc() function?

623


What are predefined functions in c?

564






Explain what are linked list?

621


What should malloc() do?

643


You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.

1781


Describe the order of precedence with regards to operators in C.

631


How do I convert a string to all upper or lower case?

627


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

908


Write program to remove duplicate in an array?

597


What is the deal on sprintf_s return value?

641


Explain the use of bit fieild.

712


Explain what are multidimensional arrays?

599