The clrscr() function is defined in the conio.h header file. It helps to clear the previous output displayed in the console or output screen.After clearing it moves the cursor to the upper left-hand corner of the screen.
clrscr();
The clrscr() function does not take any parameters.
In clrscr() function does not return any value.It clean the console window and make it ready to use by removing everything from the console.
#include <stdio.h>
#include <conio.h>
int main()
{
printf("Before clrscr");
clrscr();
printf("clrscr() will clear the screen");
return 0;
}
Output:
clrscr() will clear the screen
#include <stdio.h>
#include <conio.h>
void main()
{
int a=30, b=40;
int sum=0;
clrscr(); // use clrscr() after variable declaration
sum=a+b;
printf("Sum: %d",sum);
getch();
}
Output:
Sum: 70