Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 31-03-2005, 12:45 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2005
Posts: 42
Default Printing Multiple Times in C


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...
purifier is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 31-03-2005, 02:44 PM   #2 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default

Check this out

http://www.thinkdigit.com/forum/viewtopic.php?t=16416
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 31-03-2005, 02:46 PM   #3 (permalink)
Wise Old Owl
 
aadipa's Avatar
 
Join Date: Feb 2004
Location: Palghar, Mumbai
Posts: 1,000
Default

may be u can try recurrsion......


means function calling same function again and again.
__________________
i generally prefer quality over quantity
1 aadi + 1 aadi = 1 full ;)
aadipa is offline  
Old 31-03-2005, 02:54 PM   #4 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2005
Posts: 42
Default

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...
purifier is offline  
Old 31-03-2005, 03:49 PM   #5 (permalink)
SymbianGeek
 
Join Date: Sep 2004
Posts: 140
Default

Quote:
Originally Posted by purifier
is ternary operator a loop? because it is just a different form of if-else...
No ternary operator is no loop.
Bye.
--eminemence.
eminemence is offline  
Old 31-03-2005, 05:25 PM   #6 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2005
Posts: 42
Default

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...
purifier is offline  
Old 31-03-2005, 05:30 PM   #7 (permalink)
SymbianGeek
 
Join Date: Sep 2004
Posts: 140
Default

Quote:
Originally Posted by purifier
if it is then it is aginst the question to use it as a solution...
:roll:
Pls rephrase.
Bye.
--eminemence.
eminemence is offline  
Old 31-03-2005, 08:12 PM   #8 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2005
Posts: 42
Default

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...
purifier is offline  
Old 31-03-2005, 11:52 PM   #9 (permalink)
In The Zone
 
hafees's Avatar
 
Join Date: Feb 2004
Location: Kerala
Posts: 405
Default

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 http://www.thinkdigit.com/forum/viewtopic.php?t=16416
so that it is easy to find a topic.
__________________
Quitters Never Win & Winners Never Quit!
hafees is offline  
Old 01-04-2005, 08:25 PM   #10 (permalink)
Right Off the Assembly Line
 
Join Date: Aug 2004
Posts: 38
Default

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.....
deepak_vsoni is offline  
Old 02-04-2005, 12:01 PM   #11 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default

Quote:
Originally Posted by deepak_vsoni
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.....
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
tuxfan is offline  
Old 02-04-2005, 07:16 PM   #12 (permalink)
Right Off the Assembly Line
 
Join Date: Aug 2004
Posts: 38
Default

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]
deepak_vsoni is offline  
Old 03-04-2005, 12:17 AM   #13 (permalink)
In The Zone
 
hafees's Avatar
 
Join Date: Feb 2004
Location: Kerala
Posts: 405
Default

@purifier. .. do u 've a solution?
__________________
Quitters Never Win & Winners Never Quit!
hafees is offline  
Old 03-04-2005, 09:37 AM   #14 (permalink)
Right Off the Assembly Line
 
Join Date: Mar 2005
Posts: 42
Default

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
purifier is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by abhidev
- by clmlbx
- by Sarath
- by ico

Advertisement




All times are GMT +5.5. The time now is 03:01 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2