Progr@mming in C Language
Find me
  • Introduction
  • Computer Language
  • Programming Language
  • Low and High Level Language
  • Language Translators
  • C Language
  • Structure of C Language
  • Variables and Constants
  • Data Type , Constant Macro and Identifiers
  • Keywords, Comments and Type Casting
  • Operators with its Precedence and Associativity
  • Input and Output functions
  • Scanf
  • getch(),getche(),gets function
  • printf and puts function
  • Escape sequence
  • Format Specifeir and Feild Width Specifeir
  • Character Array,clear screen and size of operator
  • Character Input
  • Control Structure
  • Selection Structure,if statement and limitation of if statement
  • if-else and if-else if statement
  • Nested if
  • Switch Statement
  • Conditional Operator
  • Loops
  • while,do and for loop
  • Nested loop
  • Continue,goto and break statement
  • Functions
  • Variables,scope and lifetime of a variable
  • Examples

Getch Function

“The getch = get character. This function is used to get a single character input from the user” during execution of program. It also force to wait the output to stay on screen until any key pressed from keyboard.

Syntax:
  •      For value input: Variable name= getch();
  •      For screen holding at the end of program: getch();
Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr();
char m;
printf("Enter character:");
m=getch();
printf("The character you Entered=%c",m );
getch();
}

Output:
Enter character:
The character u Entered=a

Getche Function

The getche() = get character echo. It is also used to get a single character from the keyboard during the program execution. When this function is executed, the character entered by the user is displayed on the screen.

Syntax: Variable name=getche();
Example
#include<stdio.h>
#include<conio.h>
void main ()
{
clrscr();
char p;
printf("enter any character:");
p=getche();
printf("the character u entered=%c",p );
getch();
}

Output
enter any character:x
the character u entered=x


This special function is used to input string values from the user during execution of the program. As the user press enter key when typing after the string. A null character (\0) is automatically entered at the end of the string.

Syntax:
gets(variable name);

Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
char str[];
clrscr();
printf("Enter a string:");
gets(str);
getch();
}
Output:
Enter a string:hello

Powered by Create your own unique website with customizable templates.