clrscr in cpp 1

clrscr in cpp

#include
#include

void main()
{
int a=10, b=20;
int sum=0;
clrscr();  // use clrscr() after variable declaration
sum=a+b;
cout<<"Sum: "<

Here is what the above code is Doing:
1. We have declared two variables a and b and assigned values to them.
2. We have declared another variable sum and assigned value 0 to it.
3. We have used clrscr() function to clear the screen.
4. We have added the values of a and b and stored the result in sum.
5. We have displayed the value of sum on the screen.
6. We have used getch() function to hold the screen.

Similar Posts