Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

Most C++ compilers supply nonstandard functions that allow cursor positioning and the like. If a compiler supplies such functions, create a function called myclreol() using...

Most C++ compilers supply nonstandard functions that allow cursor positioning and the like. If a compiler supplies such functions, create a function called myclreol() using C++ language a function that clears the line from the current cursor position to the end of the line. However, give this function a parameter that specifies the number of character position to clear. If the parameter is not specified, automatically clear the entire line. Otherwise, clear only the number of character positions specified by the parameter.


Answers


Davis
since cursor positioning functions differ from compiler to compiler and environment to environment, only one possible solution is shown for borland C++ under a command-prompt environment.

#include
#include
using namespace std;
void myclreol(int len =- 1);
int main()
{
int i;
gotoxy(1, 1);
for(i=0; i<24; i++)
cout << "abcdefghijklmnopqrstuvwxyz1234567890\n";otoxy(1, 2);
myclreol();
gotoxy(1, 4);
myclreol(20);
return 0;
}
//clear to end line unless len parameter is specified.
void myclreol(int len)
{
int y;
x = wherex(); // get x position
y = wherey() // get y position
if(len== -1) len = 80-x;
int i = x;
for(; i<=len; i++) cout << ' ';
gotoxy(x, y); //reset the cursor
}

Githiari answered the question on May 31, 2018 at 17:39

Answer Attachments

Exams With Marking Schemes

Related Questions