ADVERTISEMENT
ADVERTISEMENT

Home » C solved programs » C tricky/puzzle programs

C program to print your name 10 times without using any loop or goto statement

In this program, we will learn how to print any message without using any loop or goto statement? . Here we will use recursionrecursion is a process by which a function calls itself.
By using recursion we can print any message N times.



/*program to print your name 10 times without 
using any loop or goto statement*/
 
#include <stdio.h>
void printName(char* name,int count) 
{ 
    printf("%03d : %s\n",count+1,name); 
    count+=1; 
    if(count<10) 
        printName(name,count); 
} 
int main() 
{ 
    char name[50];  
    printf("\nEnter you name :"); 
    scanf("%s",name); 
    printName(name,0); 
    return 0; 
}

Output

Enter you name :C-Language 
001 : C-Language 
002 : C-Language 
003 : C-Language 
004 : C-Language 
005 : C-Language 
006 : C-Language 
007 : C-Language 
008 : C-Language 
009 : C-Language 
010 : C-Language
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.