03 a powb 2 cout your bmi is c endl return

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t << “Please enter a second number:” << endl; cin >> y; z = x*x; z = z + y*y cout << “The answer is:” << sqrt(z) <<endl; { 1 #include <iostream> #include <cmath> using namespace std; 2 int main( ) 3 { 4 double x, y, z; cout << “Please enter a number:” << endl; cin >> x; cout << “Please enter a second number:” << endl; cin >> y; z = x*x; z = z + y*y; 5 cout << “The answer is:” << sqrt(z) <<endl; return 0; 6 }7 7 scaffolding declarations expressions errors #include <iostream> #include <cmath> using namespace std int main( ) { double a, b; cout << “Enter your weight in pounds: ” << endl cin >> a; cout << “Enter your height in inches: ” << endl; cin >> b; c = 7.03 * a / pow(b, 2); cout << “Your BMI is: ” << c << endl; return 0 } There are between 1 and 5 errors in the program. How many do you see? #include <iostream> #include <cmath> using namespace std; 1 int main( ) { 2 double a, b, c; cout << “Enter your weight in pounds: ” << endl; 3 cin >> a; cout << “Enter your height in inches: ” << endl; cin >> b; c = 7.03 * a / pow(b, 2); cout << “Your BMI is: ” << c << endl; return 0; 4 } 4 scaffolding declarations expressions errors Recap: Reading A C++ Program Recap: Reading A C++ Program #include <iostream> Scaffolding provides using namespace std; contextual information that // multiply a number by 7 holds the program together. Declarations provide int main ( ) information about the { double x, y; identifiers used by the cin >> x; program. y = x * 7; Expressions change and cout << y; exchange data. return 0; } From Program to Executable From Program to Executable To make use of our program we must be able to call it. The primary caller for our programs is the operating system (OS). The Operat...
View Full Document

Ask a homework question - tutors are online