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

Is there anything like an ifdef for typedefs?

692


Can you add pointers together? Why would you?

628


Where is c used?

639


How is a macro different from a function?

646


Explain how can I prevent another program from modifying part of a file that I am modifying?

625






Explain what are compound statements?

593


With the help of using classes, write a program to add two numbers.

607


Is there a way to jump out of a function or functions?

620


What does the error message "DGROUP exceeds 64K" mean?

715


What is the modulus operator?

722


Is c compiled or interpreted?

651


Difference between MAC vs. IP Addressing

629


Write a factorial program using C.

628


What is a string?

652


What are the types of data files?

708