Print a number 100 times without using loop, recursion and macro expansion in C? in Turbo C
Print a number 100 times without using loop, recursion and macro expansion in C?
It is possible to solve this problem using loop or a recursion method. And we have already seen the solution using #define directive (Macro expansion) but what if all three are not allowed?
A simple solution is to write the number 100 times in cout statement. A better solution is to use concept of Concept of setjump and longjump in C.
SOLUTION:
#include<iostream.h>
#include<setjmp.h>
jmp_buf buf;
int main()
{
static int x=1;
setjmp(buf);
cout<<"1"<<endl;
x++;
if(x<=100)
longjmp(buf,1);
return 0;
}
posted by lol ik
Comments
Post a Comment