pTutorial

New way to learn C programming

C Program to print hello

In this section we will discuss about how to print hello program in C programming language. It would display the string on console by using printf library function.

Example of printf function


//C Program of  hello C


#include <stdio.h>

#include <conoi.h>

void main()

{

  printf(" Hello and welcone to C \n");

  getch();

}


The first line of the program is a comment line that will not display on console. In this program there are two pre-processor directive "stidio" and "conio". stidio is used for printf function and conio is used getch function. Printf function diliver the result on the console and getch function is used to take single input from keyboard.

Output

c program to print hello

Example of printf function with return statement


//C Program of  hello C

#include <stdio.h>

int main()

{

  printf(" Hello and welcone to C \n");

  return 0;

}



The main is a pre define function, From where execution of C program starts.

Example of print character


// Simple C program to print character

#include <stdio.h>

#include <conio.h>

void main()

{

  char a[] = "programming language";

  printf("%s\n", a[10]);

  getch();

}



In this example "a" is a character type an array variable that hold the sequence of character and display on the console by the help of printf function.



Example of print string


//C Program print string 

#include <stdio.h>

#include <conoi.h>

void main()

{

  string str = "C programming";
  
  printf(" %s \n",str);

  getch();

}

In this example "str" is a string type variable that hold any string. You can simply print by using printf function.


QUOTES OF THE DAY

We are never deceived we deceive ourselves.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER