Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

System PAUSE and CLS

+2 votes
asked Aug 1, 2020 by FX Airell Valerio SW (140 points)
How can we use system("pause") and system("cls") in here?

3 Answers

0 votes
answered Aug 5, 2020 by Peter Minarik (86,040 points)
edited Jun 21, 2021 by Peter Minarik
Both pause and cls are Windows commands.

OnlineGDB is running on a linux machine, hence the Windows commands do not work there.

"clear" on Linux is the equivalent of "cls" on Windows, however, it does not work in here. It works in your own PC though if you're running Linux.
commented Jun 26, 2023 by Éder S. (320 points)
solution
put it library stdlib.h
and put system ("clear") ;

xxxxxx
check it code

xxxxx

#include <iostream>
#include <stdlib.h>
using namespace std;

int main () {
int n1, n2, res ;
char opc ;

inicio :
system ("clear") ;
cout << " digite nota 1 :  " ;
cin >> n1 ;
cout << " digite nota 2 : " ;
cin >> n2 ;
res = n1+n2 ;

if ( res > 60 )
cout << " aprovado \n" ;

else if ( res > 40 & res < 59 )
cout << " recuperacao \n" ;

else
cout << " reprovado \n" ;

cout << " Digitar outras notas ? [S / N ] " ;
cin >> opc ;

if ( opc == 's' or opc == 'S' )
goto inicio ;

return 0;

}
+1 vote
answered Jun 19, 2021 by lzy (170 points)

HI

Not support

They all need to use"#include < Windows.h >"

The GDPOnline IDE does not support it


Function


System (" CLS ") clears the screen
System (" pause ") can display "press any key to continue"

// If you want, download dev-cpp

0 votes
answered Aug 21, 2023 by Éder S. (320 points)
OnlineGdb work in server host linux , so need library linux to working.

Unique solution is put it library and function sleep.

check code

Éder

Brazil

#include <iostream>
#include <stdio.h>
#include <unistd.h>     // <<<<<<<<<<<<<<< HERE

using namespace std;

int pay1,minutes;

int main()  {
   
    label1:
    system("clear");
    cout<<"What value you pay ? 39, 59 or 69 ?   ";
    cin >> pay1;
    cout << "What minute you used ?   ";
    cin>> minutes;
    
   
   if (pay1 == 39 ) {  cout << "You Pay 39$ "<< "\n";
   cout << "Your total Bill is " << pay1 + minutes*0.45 << "\n" ; }
    else if ( pay1 == 59) { cout << "You Pay 59$" << "\n";  
    cout << "Your total Bill is " << pay1 + minutes*0.40 << "\n" ; }
    else if ( pay1 == 69) { cout << "You Pay 69" << "\n";  
    cout << "Your total Bill is ilimitate "  << "\n" ; }
    else {cout << "You tape value wrong" << "\n"  ;}
 sleep(5);    //  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<HERE
 
 
goto label1;
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...