Printing Multiple Times in C

Status
Not open for further replies.

purifier

Broken In
Is there any way i could print a statement multiple times in C without using any loops and conditional statements...? This question is really troubling me a lot... Can someone give me an idea on how to approach this problem please? I'm a begginer in C, so simple ideas or solutions are appreciated... Please help...
 
OP
P

purifier

Broken In
Wow...thats a wonderful post... Thanks a lot for the link tuxfan... and one more clarification is that you are not required to use even recursion(i'm sorry, i forgot to mention this)... And i need one more clarification, is ternary operator a loop? because it is just a different form of if-else...
 
OP
P

purifier

Broken In
Sorry once again, i mean, isn't ternary operator a conditional statement? or another form of if-else... and if it is then it is aginst the question to use it as a solution...
 
OP
P

purifier

Broken In
I'll give the question more clearly this time:

Write a C program that prints a statement multiple times without using:
1. Loops
2. Conditional Statements
3. Recursion

The link which was provided contained a solution which used ternary operator and recursion... but the question doen't allow us to use them...
 

hafees

In the zone
i dont think it is possible. who asked u this question. if he has a solution pls post it here.

u may use another function to do it.
eg:

main()
{
printf("\nPrinting Line... ");
func();
}
func()
{
main();
}
But this is also another form of recursion.

p.s pls post C programming related posts to the Link *www.thinkdigit.com/forum/viewtopic.php?t=16416
so that it is easy to find a topic.
 

deepak_vsoni

Broken In
you can use goto statement but you need a conditional statement to terminate the program or else it will loop infinitely (actually goto statement is not entertained much)..........or else i think its not possible.....
 

tuxfan

Technomancer
deepak_vsoni said:
you can use goto statement but you need a conditional statement to terminate the program or else it will loop infinitely (actually goto statement is not entertained much)..........or else i think its not possible.....

:shock: :shock: :shock: NEVER USE A GOTO STATEMENT. Its not only bad programming, but also makes code maintenance extremely difficult.

deepak_vsoni points out that it is not entertained much. I will say he is being modest :) It is highly discouraged.

If you properly follow the flow of logic, GOTO statement will never be required. I have made many C applications, but never ever used GOTO. Its extremely bad programming practice :(
 

deepak_vsoni

Broken In
you are right tuxfan goto statement should never be used, but in this case it was just another approx solution to his problem cause he wanted to do it without loops and recursions..[/quote]
 
OP
P

purifier

Broken In
hafees, first of all thanks for the code... i'm still working on the solution... I'll post it as soon as i get it... I'm really sorry if it takes some more time... I'll go and ask the friend who asked me this question... Wonder if he knows the solution himself :?
 
Status
Not open for further replies.
Top Bottom