Saturday 11 February 2017

print DONE 100 times without using any loop in c

when every without using loop any one asking. That means we have to give answer using recursion.



int print_done_without_loop(unsigned int times){
        if(times){
                printf("DONE\n");
                print_done_without_loop(times-1);
        }
}

Full Code


#include < stdio.h >


int print_done_without_loop(unsigned int times){
        if(times){
                printf("DONE\n");
                print_done_without_loop(times-1);
        }
}

int main(int argc, char *argv[]){
        print_done_without_loop(100);
        return 0;
}

Compile and OUT PUT


rajesh@ideapad:~/Rajesh/Blog$ gcc print_done.c
rajesh@ideapad:~/Rajesh/Blog$ ./a.out 
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE
DONE

No comments:

Post a Comment