Displaying text on Screen / Displaying desired text using printf command / Print formatted text at screen using C language function / Printing at Screen

We have earlier discussed about programming, so let’s start some real fun at C language. All you have to do is to install “Turbo C” in your computer and then you have to run Turbo C that is present in the “Bin” folder. Opening it will produce a blue window having no name; the good thing is you must save it before doing any work at it. Remember the short key for saving as it would be used again and again that is F2. Now we are beginning to the adventurous ride of C language.


The question is what we have to do if we want to display something at C language interface1 in text form? (Graphical items display would be discussed later). The answer is simple, first we have to understand the easy syntax2 of this purpose and then we would apply it according to our needs.

The first thing we have to keep in mind is the syntax we have to use, these words are case-sensitive3 and cannot afford and spelling mistake, that is wrong spelling means the words that computer don’t know. All you have to do is to learn the basic code and the remaining things would be learnt time by time when you would use it.



void main(void)





Now coming to the main task, we would display different things at the screen. The keyword used to print different things is printf, whenever we have to display the desired text we would use the printf statement. The syntax we would follow is displayed as follows:

Printf(“Desired Text”);

And the program would be like this:



void main(void)








To see the output you have to press Ctrl+F9 or you can select it from the option and pressRun. This will print www.programmingdoctors.wordpress.com at the screen.

We have used Semicolon “;” after each and every line. This is due to the end of a statement, it is also called “Statement-terminator”, that is the sentence ends at this which further clarifies that any word written after this would be counted as the next sentence.

Now your task is to print your name on the screen  and your dear ones and show them, the really cool thing. Enjoy this activity, all you have to do is to just replace the desired word with your name.

It was all about printing one line, what if we could write in different lines, like if we want to leave a line after something we can easily leave it. For this we have two ways to write, we can use both of them, but it is good approach that we would use the second one. The first one is to use separate print statement for each line.

Printf(“Desired Text1\n”);

Printf(“Desired Text2\n”);

Printf(“Desired Text3\n”);

Printf(“Desired Text4.”);

Here the “\n” is the main thing, that is used to change the line, so you can easily write multiple lines according to what you want. The second method is to use only one line and putting “\n” wherever required.

Printf(“Desired Text1\nDesired Text2\nDesired Text3\nDesired Text4.”);

Both of them will print the text in this manner:

Desired Text1

Desired Text2

Desired Text3

Desired Text4

Let’s take an example of this that will further clear the concept:



void main(void)



printf(“There are three states of matter:\n”);






Print statement can also be written by the second method:

printf(“There are three states of matter:\n1-Solid\n2-Liquid\n3-Gas.”);

The result would be same for both the programs, that would display as follows:

Now your task is to make different lists of things and display it on the screen.


Asjad Azeem.


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: