Saturday, 24 July 2021

Program to display the output using endl , clrscr() and getch() in C++

 2) Write a C++ program to display the following using endl-

Program=2

Logic=6

Documentation=2

Source code:

#include<iostream.h>

#include<conio.h>

void main()

{        

 clrscr();

cout<<"Program=2"<<endl;

cout<<"Logic=6"<<endl;

cout<<"Documentation=2"<<endl;

 

getch();

}

Output:

Output2



Note:

clrscr() and getch() both are predefined function in "conio. h" (console input output header file).
If you don’t use it in your program you wont get any error, it has some effect on the display of the output.

clrscr() - It can be expanded as clear screen and so is its purpose- to empty the buffer(memory) containing the output of previously executed programs.

getch() - It is used to make program wait for the user's input before it returns to the editing window after successful compilation and output.









No comments:

Post a Comment

Program to find and display area, circumference and diameter of a circle in C++.

Write a C++ program to find and display area, circumference and diameter of a circle.  Source code: #include<iostream.h> #include<c...