CS161_Topic#4

CS161_Topic#4 - CS161 CS161 Introduction to Computer...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS161 CS161 Introduction to Introduction to Computer Science Computer Science Topic #4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS161 Topic #4 2 Today in CS161 Assignments/Questions What is needed for Program #2? Using the Math Library Input/Output and Formatting Sample Algorithm
Background image of page 2
CS161 Topic #4 3 To Raise to Power of. .. In C++ there is no operator that will raise some number by another For example, for x 3 you can’t type: x**3 ILLEGAL! Instead, you must use the pow function float answer; answer = pow(x, 3);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS161 Topic #4 4 To Raise to Power of. .. To use the power function, we must do two very important things. .. include the math library: #include <math.h> compile our programs using a -lm flag g++ -lm prog2.cpp
Background image of page 4
CS161 Topic #4 5 Next, to Format our Output We must learn about precision By default, real numbers are displayed with no more than 6 digits, plus the decimal point This means that 6 significant digits are displayed in addition to the decimal point and a sign if the number is negative
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

CS161_Topic#4 - CS161 CS161 Introduction to Computer...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online