C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds


Posted By: Muhammed Athil     Category: C Programming     Views: 27946

For beginners why getch() is used in a c program...

Why getch() is used for?

           Most of the c program end with this statement. So most of the people thought that this program is used to get output on the screen.   But it is wrong This statement is used to read a single character from console without an echo to screen.. let see how it is....

Through a program

      printf("Hello friend");

                When you run this program using turbo c++ compiler we cannot see the output. Actually the out put was already printed on the screen , at the printing time itself the run window will close.  When you go to the user screen (window --> user screen) , you can always see what the last status of program running.  Here getch() hepls to the user for waiting to enter a character from keyboard ..

Just go through another program. 
           char name[20];
          printf("Hello friend, What is your name?\n");
          printf("Hello %s Welcome to c programming",name);
                   In this program also I not use getch() . When we run the program  We can see like this

Hello friend, What is your name?

              Here we cannot see the last statement while running. But the last statement is already printed on the screen. After printing the run window will close without any response(Entering any character) of the user. After running the program just just go to the user screen. there we can see the last statement.

Hello Athil Welcome to c programming.
      I hope that most of them understand what the use of getch() . If not then go through the bellow program

          int a,b;
          printf("Enter any two numbers\n");
         printf("Please press any key to view out out\n");
         printf("The sum of the numbers you entered is %d",a+b);


Didn't find what you were looking for? Find more on getch() Or get search suggestion and latest updates.

Muhammed Athil
Muhammed Athil author of getch() is from Calicut, India. Muhammed Athil says

Hello Everyone,I am Muhammed Athil from India

View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

Abhishek Singh from India Comment on: May 13

very well.

View All Comments