Skip to main content

How to display text on monitor

We can display the text on monitor/ screen using a standard library function "printf()".

The syntax for the "printf()" statement is

printf(" ");

printf(" Hi ");

The above statement displays "Hi' on monitor.

printf("format string", arguments list );

A format string can be : %d (integer), %s (string) , %f (floating point number), %c (character) , %lf etc.

Ex : printf ( " %d " , output); // for single output
   
Here '%d' represents an integer and 'output' is the name assigned to that integer.

printf("%d%c", output1 , output2 ); // for multiple outputs


To use printf statement in our program, we have to include a header file "stdio.h"

i.e   #include<stdio.h> or #include"stdio.h"

Comments