Enter your email address:


Monday, September 2, 2013

Home » , » WAP to print DONE,witho ut using any loop and any conditonal clause or operators.

WAP to print DONE,witho ut using any loop and any conditonal clause or operators.

Questions: Top-30-c-programs-asked-in-interview_6304.html

22.WAP to print DONE 100 times,without using any loop. // asked to my frnd in any company.

main()

static int i=1;
printf("%d . DONE\n",i);
i == 100 ? exit(0):main(++i);
}

23.WAP to print DONE,witho ut using any loop and any conditonal clause or operators.

/* This code is just in purpose to solve the above question,, but its not a good code in programmin g,as its terminatin g at divide error,,if anyone have a better code,let me know */

main()
{
static int i=100;
printf("%d . DONE\n",101-i);
main(1/--i);  // here when 1/--i =0 it should exit... depend on system may get floating issue.
}

if any one has better solution of question 23 please add it in comment i will update it with your name :)
Share this games :

3 comments:

Unknown said...

#include

/* Prints numbers from 1 to n */
void printNos(unsigned int n)
{
if(n>0)
{
printNos(n-1);
printf("%d DONE ", n);
printf("\n");
}
return;
}

/* Driver program to test printNos */
int main()
{
printNos(100);
getchar();
return 0;
}

Unknown said...

#include
#include
int main()
{
int n=100;
print(n);
return 0;
}
print(int n)
{
if(n==0)
exit(0);

printf("done\t");
print(--n);
return 0;
}

rajesh6115 said...

#include <stdio.h>
int main(int argc, const char *argv[]){
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
printf("DONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\nDONE\n");
return 0;
}

Post a Comment

Related Posts