How to underline User input

#include <iostream>
#include <cmath>
using namespace std;
int main()
{

const double pi = 3.1415926535897;
double r,h;

cout << " Enter the radius of a cone: ";
cin >> r;
cout << " Enter the height of a cone: ";

cin >> h;

double V = (1.0/3)*pi*r*r*h;

cout << " Volume : " << V << endl ;

double SA = pi*r*r + pi*r*sqrt(r*r + h*h);

cout << " Surface Area :" << SA << endl ;

return 0;
}

My instructor requires me to print out r and h as underlined numbers. I use Geany. I am stuck here. Please help me out. Thank you. I
I don't think you can on in a dos window. What kind of terminal are you using ?
The best thing to do is email your prof and politely ask how expects you to underline the numbers.

(It might be as simple as printing a whole bunch of dashes underneath the number:
    Volume : 3.14159
             -------

?)

Hope this helps.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{

const double pi = 3.1415926535897;
double r,h;

cout << " Enter the radius of a cone: ";
cin >> r;
cout << " Enter the height of a cone: ";

cin >> h;

double V = (1.0/3)*pi*r*r*h;

cout << " Volume : " << V << endl ;
cout << " ------" << endl;

double SA = pi*r*r + pi*r*sqrt(r*r + h*h);

cout << " Surface Area :" << SA << endl ;
cout << " -------" << endl;

return 0;
}







YOURE WELCOME
i think the best you can do is use the escape sequence /b along with "__".for example:-
1
2
cout<<"Enter a number:-____\b\b\b\b";
cin>>number;


the "_" symbol can be made by pressing shift and the button next to zero and between = on the top row of the keyboard.

In the first line of the code i have written "_" four times so i have to enter '\b' four times to write upon the first "_"in the line.

If you used inputted a single digit word or char in the above code your output will look like this
2___



Only use "_" and '\b' when you are a little sure of how much the user is going to enter as it could when used excessively can make input look bad.
Last edited on
@kartik17
You should try a thing before suggesting it to see if it is possible.
@Duoas i would like to know what is wrong in this approach and would be glad if you could provide a solution as i am a beginner too and it would help me too.I think this approach is good for underlining the input but not output i think.
Last edited on
Maybe I am confused. I think what you are trying to do is different from OP's request.
Topic archived. No new replies allowed.