Explaining :- clrscr (); and getch(); in C

clrscr (); and getch();

clrscr(); and getch(); requires the header file conio.h i.e #include <conio.h>

clrscr(); :- This is used for clearing the output screen i.e console

suppose you run a program, alter it and run it again you may find that the previous output is still stuck there itself, at this time clrscr(); would clean the previous screen.

One more thing to remember always use clrscr(); after the declaration like

int a,b,c;

float total;


getch(); :- getch is used to hold the screen in simple language, if u don't write this the screen

will just flash and go away....

Comments 93 comments

priyankmaniar profile image

priyankmaniar 7 years ago from Mumbai, India Author

i hope it helps. . !

nicomp profile image

nicomp 7 years ago from Ohio, USA

Good explanation; also note that conio.h is not ANSI or ISO standard.

alam 7 years ago

thanks brother i was forget it.

priyankmaniar profile image

priyankmaniar 7 years ago from Mumbai, India Author


REAl 7 years ago

Thanks man.

rimi 6 years ago


it is really useful

xyz 6 years ago

pl. note that this explanation hold water only if u r doing programing in turbo c.

azher 6 years ago

thanx for the great information

Brundaban 6 years ago

Thank a lot sir

priyankmaniar profile image

priyankmaniar 6 years ago from Mumbai, India Author

no problem guys ... thanks for commenting :)

Cheers !

kishram 6 years ago

good explaination dude...........

priyankmaniar profile image

priyankmaniar 6 years ago from Mumbai, India Author


tintin 6 years ago


rencylL 6 years ago


ahm can you try explaning about what do in the program?,what is the defination of conio.h?

kim d. 6 years ago

nice dowd .

now i knew it .

it just a simple explanation .

ur the men dowd .

Preetha 6 years ago

good explaination

Rohit 6 years ago


Arjit 6 years ago

Hi there!

I use Dev Cpp IDE for learning C as Turbo aint working on Win Vista. So, it displays error whenever I use clrscr() and getch(). Plz help. DEV cpp is available under free license.

Ahsan 6 years ago

Dev Cpp does not required clrscr() function. it only works with Turbo.

ramchandar 6 years ago

this is useful site

cath 6 years ago

cause turbo the one only recquired a clrscr(); function...

priyankmaniar profile image

priyankmaniar 6 years ago from Mumbai, India Author

thankyou everyone for your comments and appreciation.

I have only used Turbo C as IDE for C and C++ so don't know about the other IDE's. And that does require clrscr and getch :)

dixy 6 years ago

thank u

payal 6 years ago

hi.....nice explaination but plz tell me the reason to declare clrscr after variable declaration ????

vikas 6 years ago

thanks a lot .. well explained

Anand Pardeshi 6 years ago

why we have to use clrscr() after the variable declaration.

suresh 6 years ago

i want some programs,quizzes in c where i can found them

ryan 6 years ago

how to color the output!

Ashley 6 years ago

what will happen if i use clrscr() before the declaration...it comes error but i want to know why

piyapiya 6 years ago

nice explanation from every one and thanks to you all people. actaully, i am new one from c++ using visual studio 2008.. and i saw many projects with clscr() and getch(). so i was confused but now clear to some extent.

piyapiya 6 years ago

visual studio 2008 is a compiler itself..how?? please anybody explain me about compiler..

bala 6 years ago

useful info

gaurav 6 years ago

well explained

sourabh.... 6 years ago

thnx...it works correctly nw..

Fadila Fulail 6 years ago

Hmm well explained in the way that i want, thank you

praveen 6 years ago

thanks 4 well explanation of clrscr();

Khairy 6 years ago

i am using visual Studio6. Clrscr(); not working. It says , undeclared. Even, as u said, make use of coni.h. I did even then, not working.

khairy 6 years ago


One of my fellow asked about the abbreviation of conio.

So, it is console input out. Oh, i remembered, this thing my professor told me in Intro to computer programming. Well, helped me.

oindo job 5 years ago

its been really useful...

sonali 5 years ago

thanks a lot

iqra 5 years ago

hye want 2 learn c language in detail online plz help me.wat should i have 2 do.bcoz i dnt understand frm my teacher

Anirudh Banerji 5 years ago

Does anyone knows that if we do not clear the console, then the previous outputs get displayed every time we run it,So i wanted to know where are these previous output are stored. Exactly which place holds these output on the console?

Thank you

ravi256690 5 years ago

why we cant use clrscr() before declaration?

joydeep 5 years ago

thanks a lot......

punit chauhan 5 years ago

surely it'll help me..........

Pworld 5 years ago

the clrscr() is declared after declaration of variable becoz of the structure format of c..dat is the main function 1stly searches d declaration of variable den other fun. hence it gives error when declared be4..hope dis help

sanjeev 5 years ago

thanks a lot

chaitra 5 years ago

wow!gud explaination thanks lot

Priyanka 5 years ago

How we pass 2-D Array to a Function?

mithilesh kumar 5 years ago

can we use clrscr anywhere in the program? If we use then what will be the result?

uv ramana 5 years ago

Thanks and its very useful for me.

tiii 5 years ago

nice explanation................ thanx.......

sathishkumar 4 years ago

thanks.nice explanation

pratima 4 years ago

even if we does not give conio.h stil clrscr() works..


den what is the need of that header file

Rizwan 4 years ago

Very Good Ans...

Marwan 4 years ago

thanks you

Raghvendra singh 4 years ago

thanks you solve the problem

DoNa 4 years ago

Thank u ..........

nomi 4 years ago

i did it but it asks to declare clrscr();????

ARVIND KUMAR 4 years ago


Satish 4 years ago


Siddhartha 4 years ago

stupendo fantabolously fantastical,chummeshwari and now that's what i call explanation..in all total many many thnx..

sumit paul 4 years ago


kamal sharma 4 years ago

I were very confuse that how does declare both now I could able to use right way of clrscr(); and getch();


ganapthihema 4 years ago

very simple and nice definition

ajay dhakar 4 years ago

its fantastic

anbu 3 years ago


Devi 3 years ago

Thank you

sonu 3 years ago

good explanation

Muhammad Asif Raza 3 years ago

It's very helpful ...Thanks to all

mani kanth 3 years ago

thanx a lot bro.....

saawan kumar 3 years ago

clrscr();-clrscr function clears the screen

S.Kothandaraman 2 years ago

Thank u very much for the insant response in proving information.

CoderGal 2 years ago

Compact, to the point, and solves my problem

BHaradwaj 2 years ago

Thanks , Its correct way u explained

Praveen 2 years ago


its very helpful

jeyanthan 2 years ago

i need a help i just installed c++ setup from yogisoft tec., in that the display screen is not clear and numbers are hidden how can i rectify it and where can i gertt original turbo c setup

sha 2 years ago

good expanation

thank you

yar muhammad 2 years ago

Thanks of your well explanation

I have understood perfectly

sky 2 years ago


rajini 2 years ago

Its useful

kannan 2 years ago

u r good expliner

sasi 2 years ago

Its useful

veer 2 years ago

This helps me lot to understanding the program

Yash singhal 24 months ago

Really its great for studying.........

saqi gujjar 23 months ago

its very easy to solve problems

mukesh mahato 23 months ago

Thank you so much

Ivan 22 months ago

Thank you man, best regards.

pranav 20 months ago

thanks man

tania sarkar 16 months ago

Thnk u so much.....

ganesh kumar 11 months ago

correct ans

p.meena 7 months ago

Thank you sir.

madhuri 2 months ago

This was really in very simple language.Thank u sir....

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.

    Click to Rate This Article