Hello, World! : C Program

Computer Science » C Program » Hello, World!

Definition :

Here you will learn, How to print “Hello, World!” on the screen in C programming.

Image :

Program :

#include<stdio.h>

int main()
{
   printf("Hello, World!");
   return 0;
}

Output :

Hello, World!

Explanation :

1. The  #include  is a preprocessor command that tells the compiler to include the contents of  stdio.h  (standard input and output) file in the program.
2. The  stdio.h  file contains functions such as  scanf()  and  printf()  to take input and display output respectively. In the above  Hello, World!  program we are using  printf()  function.
3. If you use the  printf()  function without writing  #include <stdio.h> , the program will not compile.
4. Here  main()  is the function name and  int  is the return type of this function. The execution of a C program starts from the  main()  function. The main function is a part of every ‘C’ program. We can represent the main function in various forms, such as:

  • main()
  • int main()
  • void main()
  • main(void)
  • void main(void)
  • int main(void)

5.  printf()  is a library function to send formatted output to the screen. In this program,  printf()  displays  Hello, World!  text on the screen within double quotes.
6. The  return 0;  statement is the “Exit status” of the program. In simple terms, the program ends with this statement. The value 0 means successful execution of main() function.

Related Posts

  • 1-10 Numbers in Pyramid : C ProgramComputer Science » C Program » 1-10 Numbers in Pyramid Program : [php]#include<stdio.h> int main() { int i, j; int count = 1; for (i = 0; i <= 4; i++) { printf("n"); for (j = 0; j < i; j++) { printf("%dt", count); count++; } } return(0); }[/php] Output : [php]1 2 3 4 5 6 7 8 9 10 [/php]
    Tags: program, computer, science, output, programs
  • Inverted Pyramid : C ProgramComputer Science » C Program » Inverted Pyramid  Program : [php]#include<stdio.h> int main() { int i, j; char ch = '*'; for (i = 4; i >= 0; i--) { printf("n"); for (j = 0; j < i; j++) printf("%c", ch); } return(0); }[/php] Output : [php]**** *** ** *[/php]
    Tags: program, computer, science, output, programs
  • Program to Print All ASCII Value : C ProgramComputer Science » C Program » Program to Print All ASCII Value Program : [php]#include<stdio.h> int main() { int i = 0; char ch; for (i = 0; i < 256; i++) { printf("%c ", ch); ch = ch + 1; }[/php] Output : [php]Å É æ Æ ô ö ò û ù ÿ Ö Ü ¢ £ ¥ ₧ ƒ á í ó ú ñ Ñ ª º ¿ ⌐ ¬ ½ ¼ ¡ « » ░ ▒ ▓ │ ┤ ╡ ╢ ╖ ╕ ╣ ║ ╗ ╝ ╜ ╛ ┐ └ ┴ ┬ ├ ─ ┼ ╞ ╟ ╚ ╔ ╩ ╦ ╠ ═ ╬ ╧ ╨ ╤ ╥ ╙ ╘ ╒ ╓ ╫ ╪ ┘ ┌ █ ▄ ▌ ▐ ▀ α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■ ☺ ☻ ♥ ♦ ♣ ♠ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ ← ∟ ↔ ▲ ▼ ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6…
    Tags: program, computer, science, output, programs
  • Even Number Pyramid : C ProgramComputer Science » C Program » Even Number Pyramid Program : [php]#include&lt;stdio.h&gt; int main() { int i, j, num = 2; for (i = 0; i &lt; 4; i++) { num = 2; for (j = 0; j &lt;= i; j++) { printf(&quot;%dt&quot;, num); num = num + 2; } printf(&quot;n&quot;); } return (0); }[/php] Output : [php]2 2 4 2 4 6 2 4 6 8 [/php]
    Tags: program, computer, science, output, programs
  • Reverse a Given Number : C ProgramComputer Science » C Program » Reverse a Given Number  Program : [php]#include<stdio.h> int main() { int num, rem, rev = 0; printf("nEnter any number to be reversed : "); scanf("%d", &num); while (num >= 1) { rem = num % 10; rev = rev * 10 + rem; num = num / 10; } printf("nReversed Number : %d", rev); return (0); }[/php] Output : [php]Enter any number to be reversed : 123 Reversed Number : 321[/php]
    Tags: program, computer, science, output, programs

LEAVE A REPLY

Please enter your comment!
Please enter your name here