C Program to Print Hello world n times using While loop

In this C tutorial we will learn how we can print a certain word repeatedly like printing “Hello world” for n times . There are several ways to print Hello world n times but we will do it using while loop , and Achieve our output of C Program to Print Hello world n times using While loop.

Program Outline

In this Program first we’ll take a number as a input by the user .That number indicates how many times they want to print Hello world and then by using While loop we perform our task.

Concepts

To write this C program of Printing Hello world n times , you need to learn few concepts before heading towards writing code. Those Concepts are –

The main Concept we are going to use in this program is while loop. First we take a number as a input by the user and then assign it to a variable which we created. Then by using While loop we can print Hello world as many times as user wanted to print.

While loop

The Syntax of While loop is :

While (Condition) 
{
    // the body of the loop 
}

Program

After understanding the Concept behind this program let’s head towards writing it.

#include<stdio.h>
int main()
{
  int n,i;
  printf("How many times you want to print Hello World:");
   
  scanf("%d",&n);
   
  while(i<n)
  { 
    printf("Hello World\n");
    i++;
  }
  printf("End");
  return 0;
   
}

Output

After writing the C Program to print Hello world n times using While loop let’s check the output what we are getting after running this program. After taking input number as 5.

C Program to Print Hello world n times using While loop

If you find something incorrect or have any questions or feedback please comment down below Thank you.

Default image
groot

Leave a Reply

Your email address will not be published.