Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Simple 'if else' code not being executed

$
0
0
I have some very simple code which all runs fine apart from the if/else code I have tried to include at the end. The program allows me to enter the variables I have defined but then finishes and closes, and does not cout whether or not the element is a beam. I am new to coding and know that I have made a very simple mistake. All help is appreciated.

#include <iostream>

using namespace std;

int main ()
{

double span, depth, width;
	
cout << "Please enter beam span [mm]:"
	<< endl;
cin >> span;

cout << "Please enter beam depth [mm]:"
	<< endl;
cin >> depth;

cout << "Please enter beam width [mm]:"
	<< endl;
cin >> width;

if (span>=3*depth)
	cout << "Your element is a beam and this program will run your calculations."
	<< endl;
else 
	cout << "Your element is not a beam and this program can not run your calculations."
	<< endl;

return 0;
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>