By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,925 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,925 IT Pros & Developers. It's quick & easy.

How to print a string name for 500 times ??

P: 12
Hi All

Can anybody tell me
How to print a string name 500 times(or some 'n' number of times ) without using loops ?


Thanks In advance'
Pradi !
Dec 18 '06 #1
Share this Question
Share on Google+
4 Replies


P: 6
Hi All

Can anybody tell me
How to print a string name 500 times(or some 'n' number of times ) without using loops ?


Thanks In advance'
Pradi !

main()
{
char name[500][50];
int i=0,n;
scanf("%d",&n);
x : if(i<=n)
{
printf("Enter string");
gets(name[i]);
goto x;
}
}
Dec 18 '06 #2

100+
P: 1,646
Hi All

Can anybody tell me
How to print a string name 500 times(or some 'n' number of times ) without using loops ?


Thanks In advance'
Pradi !
Hi
You could use a recursive function which, technically, is not a loop. It is a function that calls itself.

Expand|Select|Wrap|Line Numbers
  1. void printme(long howmany, char *message)
  2. {
  3.    //print the message how you want here
  4.    howmany--;
  5.    if (howmany == 0)
  6.       return;
  7.    printme(howmany, message);
  8. }
Dec 18 '06 #3

P: 12
Thanks a lot
Pradi !


Hi
You could use a recursive function which, technically, is not a loop. It is a function that calls itself.

Expand|Select|Wrap|Line Numbers
  1. void printme(long howmany, char *message)
  2. {
  3.    //print the message how you want here
  4.    howmany--;
  5.    if (howmany == 0)
  6.       return;
  7.    printme(howmany, message);
  8. }
Dec 18 '06 #4

100+
P: 1,646
Thanks a lot
Pradi !
Welcome a lot :)
Dec 18 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.