hello, We use clear screen for clear console woindow..
We use clrscr(); for clear screen.
But 1stly we add its header file, which is conio.h ..
like
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"Waw screen is clear";
getch();
}
If yoe are not include conio.h then its creat an error..
i make 1 very wonderful code for all new comers n youngers...
// For All new Comers Student....
#include<iostream.h>
#include<conio.h> // We use conio to get output on console secreen..
// Its also use for Clear screen
#include<stdlib.h> // use for exit();
void main()
{
clrscr(); //---> Must be put on start:P..
int op;
int n1,n2;
while(1) // use for infinite n 5 for exit.
{
clrscr(); // --->> This clr scr use for clear screen on every keys u enter..
cout<<"Enter 1 for addition.. "<<endl;
cout<<"Enter 2 for Subtraction.. "<<endl;
cout<<"Enter 3 for multiplication.. "<<endl;
cout<<"Enter 4 for division.. "<<endl;
cout<<"Enter 5 for Exit.. "<<endl;
op=getche(); // u get chracter instead of integer so loop not b infinite
cout<<endl;
switch(op) // ye use switch or if else conditional staement..
{
case '1':
cout<<"Enter n1: "; cin>>n1;
cout<<"Enter n2: "; cin>>n2;
cout<<"Additin answer is: "<<n1+n2<<endl;
getch();
break;
case '2':
cout<<"Enter n1: "; cin>>n1;
cout<<"Enter n2: "; cin>>n2;
if(n1>n2)
{
cout<<"Subtraction answer is: "<<n1-n2<<endl;
getch();
}
else
{
cout<<"Subtraction answer is: "<<n2-n1<<endl;
getch();
}
break;
case '3':
cout<<"Enter n1: "; cin>>n1;
cout<<"Enter n2: "; cin>>n2;
cout<<"Multiplication answer is: "<<n1*n2;
getch();
break;
case '4':
cout<<"Enter n1: "; cin>>n1;
cout<<"Enter n2: "; cin>>n2;
if(n1>n2)
{
cout<<"Division answer is: "<<n1/n2<<endl;
getch();
}
else
{
cout<<"Divison answer is: "<<n2/n1<<endl;
getch();
}
break;
case '5':
cout<<"Program is Exit..";
getch(); //use getch or delay..
exit(1); // is just read 1 above state ment
// if u put 2 instead of 1, then its print above 2 statement..
break;
}
}
getch();
}
For more contact:
[email protected]