Formulas with powers and roots
Creating formulas that contain powers and square root.
Learning Objectives
- Using formulas with powers and roots.
- Learning to build entire formula on right hand side only.
Source Code
|
|
Run Output
Code Understanding
#include <math.h>
This include files is required to use the sqrt() and pow() function while building the formulas.
c=sqrt(pow(a,2)+pow(b,2));
This is C++ representation of a popular formula c2=a2+b2 . Since left hand side can not contain an expression so we build the entire formula on the right hand side only. For this the entire formula will be square root of a square + b square. For this reason the c++ functions sqrt() and pow() has been used. These functions are defined in math.h
Notes
- The header file <cmath> may be used for modern compilers in place of <math.h>
Suggested Filename(s): power-expression.cpp, powers-and-roots.cpp
Created: 20-Dec-2017 02:45 | Updated: 15-Sep-2018 10:49|
