C program to print "Hello"

C program to print "Hello"
//First C program to print "Hello".
#include <stdio.h>
#include <conio.h>
void main()
{
  printf("Hello world");
getch();
}

Expected Output:  Hello world


Save the program with the name: hello.c

#include<stdio.h>

  • With this line of code we include a file called stdio.h. (Standard Input/Output header file).
  • It define some standard input and outputs which are given by user

void main()

This is main function  and from here the main program gets starts.

{}

The main program lies between these brackets.

printf(“Hello World\n”);

The printf is used for printing things on the screen, in this case the words: Hello World. OR whatever you type between " ".
Commonly used escape sequences are:
  • \n (newline)
  • \t (tab)
  • \v (vertical tab)
  • \f (new page)
  • \b (backspace)
  • \r (carriage return)
After the last round bracket there must be a semi-colon. The semi-colon shows that it is the end of the command. (So in the future, don’t forget to put a semi-colon if a command ended).

return 0;

Return is used to return something or value whatever you want.
But "return 0" return nothing at place of it we can use "void"

Post a Comment

Previous Post Next Post