Formulas with powers and roots – CSKC
Sign In

Search

Code Learning #CPP#1824    siteicon   siteicon  

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

TC++ #1824

 

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

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



Share

Created: 20-Dec-2017 02:45 | Updated: 15-Sep-2018 10:49|