Building Simple Formulas – CSKC
Sign In

Search

Code Learning #CPP#7585    siteicon   siteicon  

Building Simple Formulas

Source Code

TC++ #7585

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

  Related ( ? ) :

Code Understanding

This program calculates the area of a triangle when the base and height are given by the user.
• #include allows input and output commands.
• using namespace std; lets us use cout and cin without writing std::.
• float base, height; creates two variables to store decimal values.
• cout << “Give base and height :”; asks the user for input. • cin >> base >> height; takes base and height from the user.
• float area = base * height / 2; calculates the area using the formula ½ × base × height.
• cout << “The Area of a triangle…” displays the result.
• return 0; ends the program.


Share

Created: 28-Feb-2026 20:46 | Updated: 27-Aug-2026 17:24|