|
In English, the Square of a number is the number raised to the power of two (or, multiplied by itself).
The Square Root of a number is "that number or quantity which, multiplied by itself, produces the given number."
sqrt
Calculates the square root.
double sqrt( double x );
Example
/* SQRT.C: This program calculates a square root. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
double question = 45.35, answer;
answer = sqrt( question );
if( question < 0 )
printf( "Error: sqrt returns %.2f\n, answer" );
else
printf( "The square root of %.2f is %.2f\n", question, answer );
}
Output
The square root of 45.35 is 6.73
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
The best way is just to multiply it by itself. Using pow is fine but not as efficient as simply multiplying the number by itself as it’s more general. Defining a macro is not a good idea (I can hear the screams of people objecting already): prefer inline functions to macros. There are many reasons for this, including:
- Macros are hard to debug. For example try stepping into a macro.
- Macros don't respect the C++ language rules. For example you can't put them into namespaces or use function overloading.
- Macros can have side effects which are very hard to identify and debug.
Macros have their place but most C++ programmers overuse them.
Steve
|
|
|
|
|
Than you for the great lesson :
I can add olso that they could be coded into a slower code:
(see my prev post and...)
SQR(3+5*7-6+sqr(5.9))
will be, unfortunatly , coded into
( 3+5*7-6+sqr(5.9)) ) * ( 3+5*7-6+sqr(5.9)) )
and we can say goodbye to the powerfull C++!
(Sorry, but nobody will read this post! )
|
|
|
|
|
simple Linda
you do this
double squared(double dNumberIn)
{
return dNumberIn *= dNumberIn;
}
all the best Alton
|
|
|
|
|
Hi all,
if i use this code in my derived CWndEx class:
BOOL CWndEx::PreTranslateMessage(MSG* pMsg)
{
if( IsDialogMessage( pMsg ) )
return TRUE;
else
return CWnd::PreTranslateMessage( pMsg );
}
then standing on a button in my CWndEx and pressing Tab key move me to the other controls in my CWndEx class. i have a child dialog in my CWndEx class and hiting the tab also step in the dialog's control. trouble is pressing the tab within the dialog will never get me back to the controls in CWndEx?
in more simple words : i can step into the dialog using the tab, but i can't step out of it using the tab , it keeps looping the controls inside the child dialog
any suggestions?
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
YaronNir wrote: in more simple words : i can step into the dialog using the tab, but i can't step out of it using the tab , it keeps looping the controls inside the child dialog
because once i enter the Dialog, Window start treating it as Dialog message!, there fore you seeing that behaviour!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi guys,
I would like to know how can I connect my application to a mdb file.
I just wrote some others classes for this project. And the others are all in pure c++.
How can I do that?
tnx
|
|
|
|
|
Try ADO .
Make use the msado15.dll. It has a bunch of COM interfaces that serves all your DB needs.
#import "c:\Program Files\Common Files\System\ADO\msado15.dll"
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
ehm... where can i find the list of functions?
|
|
|
|
|
|
|
Salvodif wrote: I would like to know how can I connect my application to a mdb file.
See if this article is of any help.
"The largest fire starts with but the smallest spark." - David Crow
|
|
|
|
|
Hi,
I have MFC extension dll which contains some controls derived from standard Tree Controls class.
Now when i use these DLL an creating control on Dialog box at runtime it woks fine and the control is shown. But when i am initializing controls from DLL. these are not shown and its gives expection. When debugged. its fails at
-->HTREEITEM one = mytree.InsertItem("XYZ"); I guess, its giving expection at ::IsWindow(m_hWnd) and some how it is not getting the values of
m_hWnd in my case.
Can someone throw light on these and why works on Simple Dialog and not Property Page.
Thanks in advance
Abhi Lahare
|
|
|
|
|
I believe the OnInitDialog() function for the Property Page has to be called first before you can use controls in it. So make sure that OnInitDialog() for the page is being called first.
This is just a guess. It could be something else also.
this is this.
|
|
|
|
|
|
I think the problem is when you add points to the array.
Could you show the code where you are doing it?
It is actually a CPtrArray , and it is supposed to take different objects each time you add to it. You should new a CPoint etc variable and then add it to the array.
this is this.
|
|
|
|
|
Yes, OnDraw gets called in that case. Try to use your debugger to watch your data. Press F5 to start the debugger and F9 to put breakpoints. Try putting a brakpoint in the OnDraw function.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
I have the files "AA.doc" , "BB.doc" and "CC.doc", i want to create a zipp folder having these files in it. so i think they will compressed in end.
thanks for reply
Regards.
|
|
|
|
|
That zipp folder can be created on all windows operating system.
If not then any compressed type folder that contain these different file in it , i have to send that folder on network, i want to reduce the size
Regards.
|
|
|
|
|
|
Hi,
I want to send an image to MFC ActiveX Control which need to be in VC++.Net. How can accomplish this. In ActiveX control i need to display that image.
|
|
|
|
|
Ok, I hope I put this in the correct forum. Please bare with me as the question is rather long.
The development environment I am working in is Labwindows/CVI 6.0 (http://www.ni.com/lwcvi/) for the application and visual c++ 6.0 for the GINA.
For an application I was trying to lock the keyboard. Users could then unlock the keyboard by choosing a menu item after which a password box is displayed where a user can enter the password to unlock the keyboard.
I did this by creating a low level keyboard hook to catch all keys except ctrl-alt-del which cannot be intercepted this way. To make sure the password would not be blocked by the lock I would check if the password input field was the active control and if so, some keys would work (letters, numbers, backspace, enter)
To catch ctrl-alt-del I created a GINA stub based on the ginastub example in MSDN. I would then set a mutex in the application when it was locked. After pressing ctrl-alt-del the custom GINA would look for the mutex and block ctrl-alt-del if it found the mutex.
The problem was that when the keyboard was locked, after pressing ctrl-alt-del it wasn't possible anymore to give the password. The letters would just not appear on the screen. It took me some time to figure it out but the solution was to never block the ctrl button in the hook function.
Although I got the solution now I am very curious as to why it is necessary to never block the ctrl button.
I can post some sample code if required.
|
|
|
|
|
can u give me the code to use shellexecute to call a help file(.hlp).i have created the help using visual studios help workshop and NOT HTML HELP WORKSHOP. i think both r different. so please help me in this regard. also if there is any other code that can be used to call the help file pls let me know.
Thanks
|
|
|
|
|
Hi
Please search on MSDN help about ShellExecuteEx
KK
|
|
|
|
|
Hi,
why dnt u try MSDN ?? u will find lots of examples there.
|
|
|
|