How to write a sample C program to print Hello World? It is the first program to start any programming language. The “Hello World” program helps to understand the basic programming structure of C Programming. So let see how we can write print Hello World using C language.
#include <stdio.h> int main() { printf("Hello World\n"); return 0; }
Output:
Hello World
Explanation:
You can see the within the program to print hello world, I have included the “stdio.h“. The “stdio.h” is a standard input-output header file. This file allows you to use standard functions such as printf and scant. If you will not add this header file then we will get a warning. In the mentioned C program, I am using the print function to print my message on the console.
Watch this video to see how to print hello world using the printf function in C programming.
As we know there are a lot of formats specifies available in C programming. So if you want you can also print the “Hello World” C program using the character variable.
You can also see this article, C format specifiers.
#include <stdio.h> int main() { char a = 'H', b = 'e', c = 'l', d = 'o'; char e = 'W', f = 'r', g = 'd'; printf("%c%c%c%c%c %c%c%c%c%c\n", a, b, c, c, d, e, d, f, c, g); return 0; }
Output:
Hello World
Recommended Post for you:
- Write C program to add two numbers
- Write C program to find the sum of digits of a number
- C program to find largest of two given numbers
- C program to find largest of three given numbers
- C program to print 1 to 100 without using Loop
- C program to calculate the value of nCr
- C program to calculate the value of nPr
- C program to find LCM and HCF of two numbers
- C program to Print Square Star Pattern
- C program to print hollow square of stars
- C program to print hollow square star pattern with diagonal
- Write C program to create a simple calculator
- C program to convert Celsius to Fahrenheit
- C program to convert Fahrenheit to celsiusĀ
- C program for Fahrenheit to Kelvin conversion
- C program to convert decimal to binary number
- C program to decimal to binary using recursion and without using power operator
- C program to decimal to binary number using recursion