Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Monday 10 June 2019

Tricky Interview#5

Question:
How would you write a C program to print 1 to 100 without loop, recursion, or goto?

Solution:

#include<stdio.h>

void hundred() { static int i=1; printf("%d\n",i++); }

void  twenty(){ hundred(),hundred(),hundred(),hundred(),hundred(); }

void four() { twenty(),twenty(),twenty(),twenty(),twenty(); }

int main()
{
    four(),four(),four(),four();

}

0 comments:

Post a Comment