 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to print a name multiple times without loop statement using C language?
Problem
Try to print a name 10 times without using any loop or goto statement in C programming language.
Solution
Generally, looping statements are used to repeat the block of code until condition is false.
Example1
In this program, we are trying to print a name 10 times without using loop or goto statements.
#include <stdio.h>
void printname(char* name,int count){
   printf("%03d : %s
",count+1,name);
   count+=1;
   if(count<10)
      printname(name,count);
}
int main(){
   char name[50];
   printf("
Enter you name :");
   scanf("%s",name);
   printname(name,0);
   return 0;
}
Output
Enter you name :tutorialspoint 001 : tutorialspoint 002 : tutorialspoint 003 : tutorialspoint 004 : tutorialspoint 005 : tutorialspoint 006 : tutorialspoint 007 : tutorialspoint 008 : tutorialspoint 009 : tutorialspoint 010 : tutorialspoint
Example 2
Below is the program to print your name 10 times using any loop or goto statement −
#include <stdio.h>
int main(){
   char name[50],i;
   printf("
Enter you name :");
   scanf("%s",name);
   for(i=0;i<10;i++){
      printf("%s
",name);
   }
   return 0;
}
Output
Enter you name :TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint TutorialsPoint
Advertisements
                    