hackermen5
asked on
How to add an exponent to a number to be displayed in C++ ????
hi guys.....
i'm new to programming..... but i'm learning :)
we all know that pow(x,2) means x to the power 2 ..
but my question is : how to display the real symbol(the exponent 2)in the C++ program when u execute it??
i've tried to copy it from the wnidows character map, but it didn't work... it gave me some funny symbols...
please i need help ASAP.... it will be in my next week project...
thankz a lot...
i'm new to programming..... but i'm learning :)
we all know that pow(x,2) means x to the power 2 ..
but my question is : how to display the real symbol(the exponent 2)in the C++ program when u execute it??
i've tried to copy it from the wnidows character map, but it didn't work... it gave me some funny symbols...
please i need help ASAP.... it will be in my next week project...
thankz a lot...
x²
It'll appear fine on the DOS screen.
Mayank.
Mayank.
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
Yeah! I understood that. And my solution was supposed to be for that only. Put it in quotes in the cout << statement, like:
cout << "x<ALT-253> = " << pow ( x, 2 ) ; // press Alt-253 at <ALT-253>
Mayank.
cout << "x<ALT-253> = " << pow ( x, 2 ) ; // press Alt-253 at <ALT-253>
Mayank.
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
Please refer to my previous post, between your triple-posts.
Mayank.
Mayank.
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
The problem is that the small 2 in the upper corner isn't a valid ascii character. It is defined in the extended ANSI character set used by windows and it is also defined in Unicode so if you use either of those you can display it by simply using the code for that char.
int x = 3;
cout << x << '²' << endl;
should do the trick.
The main problem here is if your output translates or encodes a character set that does not support such a character - since it isn't plain ASCII.
If so you must look at your character output and perhaps examine what codepage etc you're using. It should work fine when all that is in place though.
Alf
int x = 3;
cout << x << '²' << endl;
should do the trick.
The main problem here is if your output translates or encodes a character set that does not support such a character - since it isn't plain ASCII.
If so you must look at your character output and perhaps examine what codepage etc you're using. It should work fine when all that is in place though.
Alf
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
Hackerman5.... you have posted that comment at least 4 times. In case you're working on DOS (Turbo C++), I have provided you the solution in one of my previous posts.
Mayank.
Mayank.
ASKER
no, the problem is that i want it to be displayed in the cout<<
so, it's not an input, it's an output....
so, it's not an input, it's an output....
Hackerman5....
You have posted that comment at least 5 times now.
In case you're working on DOS (Turbo C++), I have provided you the solution in one of my previous posts.
Mayank.
PLEASE DON'T CLICK ON 'REFRESH' TO REFRESH THIS PAGE BUT CLICK ON THE 'RELOAD THIS QUESTION' LINK PROVIDED AT THE LEFT HAND SIDE.
You have posted that comment at least 5 times now.
In case you're working on DOS (Turbo C++), I have provided you the solution in one of my previous posts.
Mayank.
PLEASE DON'T CLICK ON 'REFRESH' TO REFRESH THIS PAGE BUT CLICK ON THE 'RELOAD THIS QUESTION' LINK PROVIDED AT THE LEFT HAND SIDE.
cout << "x<ALT-253> = " << pow ( x, 2 ) ; // press Alt-253 at <ALT-253>
ASKER
opps, i don't why my post was repeating itself, maybe because i was refreshing the page ....i'm so sorry about that......
question for salte...u told me "you must look at your character output and perhaps examine what codepage etc you're using"
my question is "How can i examine the codepage? "
as i said earlier, i'm a beginner..... :)
question for salte...u told me "you must look at your character output and perhaps examine what codepage etc you're using"
my question is "How can i examine the codepage? "
as i said earlier, i'm a beginner..... :)
>> maybe because i was refreshing the page
Yeah! I told you to click on 'RELOAD THIS QUESTION'.
But you still haven't told me which platform you are working upon. If on DOS, then you have the solution above in my last comment.
Mayank.
Yeah! I told you to click on 'RELOAD THIS QUESTION'.
But you still haven't told me which platform you are working upon. If on DOS, then you have the solution above in my last comment.
Mayank.
ASKER
mayankeagle..... i know u r mad at me... calm down...
i was busy trying ur solution on the compiler.... i'm using visual c++ .... and it executes in DOS...
sorry again for repeating the posts......
i was busy trying ur solution on the compiler.... i'm using visual c++ .... and it executes in DOS...
sorry again for repeating the posts......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it worked :)
thankz a lot mayanak and salte....
thankz a lot mayanak and salte....
By real symbol, do you mean to see the small '2' as though in x-square (mathematical representation). If so, then in case you're working on DOS, just press Alt-253.
Mayank.