C++ Hypotenuse calculator practice program 📐

preview_player
Показать описание
#C++ #hypotenuse #calculator

How to calculate the hypotenuse of a right triangle using C++
Рекомендации по теме
Комментарии
Автор

#include <iostream>
#include <cmath>

int main()
{
double a;
double b;
double c;

std::cout << "Enter side A: ";
std::cin >> a;

std::cout << "Enter size B: ";
std::cin >> b;

c = sqrt(pow(a, 2) + pow(b, 2));

std::cout << "side C: " << c;

return 0;
}

BroCodez
Автор

These types of practices are actually really important in order to get used to a programming language. I think every programming language guide needs these types of practices. And if your a beginner, Please do NOT neglect these. They are extremely important in order to grasp a language.

smilweyboi
Автор

tq for everything Bro Code <3 from North Borneo also please take care and stay healthy

jaffnimanlangit
Автор

Thank you very much, you are such an inspiration for me. Could you do a video on Packaging JavaFX Applications, there are no videos at all on youtube about that?

khushthakor
Автор

Bro code long live your family ❤️🙏🙏You are a savior

mahdihasanpiar
Автор

Can you explain threads in your next video ?

Leen-plvm
Автор

#include <iostream>

int hypotenuce() {

int Bace;
int Height;

std::cout << "enter height of triangle" << std::endl;
std::cin >> Height;

std::cout << "enter bace of the triangle" << std::endl;
std::cin >> Bace;

std::cout << "hypotenuce is:" << std::endl;

int hypotenuce = sqrt((Bace * Bace) + (Height * Height));
return hypotenuce;
}



int main() {
std::cout << hypotenuce();
}

aniketinamdar
Автор

Since we're including cmath might as well use the hypot() function. Yeah, C is so easy you don't even need to know the Pythagorian formula to calculate the hypotenuse 😎

subnumeric
Автор

using namespace std; isn't it convenient if you type it in?

Davron-iq
Автор

Good Video. Here I don't really make notes🤣

FrederikWollert
Автор

you can use "using namespace std ; " after "include" instead of using "std::" in every line

arooba
Автор

U can say that c = hypot(a, b);
There is a built in function in cmath

jurescuiacob
Автор

ok so here's a calculator to find any side of a right-angled triangle (pls can you review it BRO?)
// hypotenuse calculator

#include <iostream>
#include <cmath>

int main(){
double a; //base
double b; //height
double c; //hypo
std::string side;

std::cout << "Which side do you want to find? \n";
std::cin >> side;
std::cout << "let us find " << side << "\n";

if(side=="base"){
std::cout << "enter height \n";
std::cin >> b;
std::cout << "enter hypo \n";
std::cin >> c;

if(c>b){
a=sqrt(pow(c, 2)-pow(b, 2));
std::cout << "base is : " << a;
}else{
std::cout << "hypo must be greater than height";
}
}
else if(side=="height"){
std::cout << "enter base \n";
std::cin >> a;
std::cout << "enter hypo \n";
std::cin >> c;

if(c>a){
b=sqrt(pow(c, 2)-pow(a, 2));
std::cout << "height is : " << b;
}else{
std::cout << "hypo must be greater than base";
}
}
else if(side=="hypo"){
std::cout << "enter height \n";
std::cin >> b;
std::cout << "enter base \n";
std::cin >> a;

c=sqrt(pow(b, 2)+pow(a, 2));

std::cout << "hypo is : " << c;
}

return 0;
}

DhruvSoni-rf
Автор

Bro are you know React.js?(with redux)

AmericanDragon
Автор

How come this goes to a new line after user input? U didn't use a /n...?

eeneemeenee
Автор

if you don't want to type "std::" every time, you can write this at the beginning of the file: "using namespace std;", then you can just use "cin" and "cout"

thebezierguy