Sample C Program to Print Hello World

How to write a sample C program to Print Hello World?. It is the basic and traditional program to start any programming language. It also helps you to understand the basic programming structure of C Programming.

Sample C Program to Print Hello World

This sample program will print the hello world.

/* C Sample Program to Print Hello World */

#include <stdio.h>
int main()
{
  printf("\n Hello World");
  return 0;
}
 Hello World

Within this Sample Program to print hello world, first, we included the stdio.h, which is a standard input-output header file. This file allows you to use standard functions such as printf and scanf.

#include <stdio.h>

The following C Programming printf statement will print the message Hello World.

printf("\n Hello World");

Print Hello World Multiple Times

In this program, we are using the For Loop to print the same statement multiple times. You can also use While Loop, or Do While to get the same result.

/* Sample C Program to Print Hello World */

#include <stdio.h>
int main()
{
	int i;
	for (i = 1; i <= 5; i++)
	{
		printf("\n Hello World");
	}
	return 0;
}
Simple C Program to Print Hello World 2

C Program to Print Hello World using Functions

In this sample program, we are using the Functions concept to print the message: Hello World.

/* Sample C Program to Print Hello World */

#include <stdio.h>
void PrintHelloWorld();
int main()
{
	PrintHelloWorld();
	return 0;
}
void PrintHelloWorld()
{
	printf("\n Hello World");
}
 
Hello World

Comments are closed.