In this program we will print hello world as many times as we want by using loop 
   now if you are a beginner you must be thinking what is this loop?
   so , for a quick use  you can take a loop as a way to print your statements desired no 
   of times otherwise you will need to write printf() function as many times as you want
   but you can write printf  10 or 20 times or more but what if you have to write a 
   single code 100  times so, we need loop for that which makes it easier... 

 Program
  
  #include<stdio.h>
  #include<conio.h>
  void main()
  { 
   int n =1 , m; 
   printf(“Enter the number of times you want to print = “);
   scanf(“%d”,&m);
   while (n<= m) 
     { 
      printf("%d) Welcome in C Programming\n",n);
      n++; 
      }
   } 
  Output:

Now , let's understand the program  as you can see in the output window that user is asked to input the number of times he/she wants to print the statement for that we have used the printf() and scanf() function and to make output more beautiful you can use a format specifier %d  as i have used so it will increase as n increase because it is taking value of n..

Post a Comment

Previous Post Next Post