0% found this document useful (0 votes)
120 views

Assignment Formatting and Interactive Input

The document discusses various C++ programming concepts including assignment operations, coercion, formatting numbers for output, mathematical library functions, program input using cin, symbolic constants, and placement of statements. It provides examples and explanations of each concept. The document is authored by Mr. Orestes Mendoza and covers fundamental programming topics.

Uploaded by

Orestes Mendoza
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Assignment Formatting and Interactive Input

The document discusses various C++ programming concepts including assignment operations, coercion, formatting numbers for output, mathematical library functions, program input using cin, symbolic constants, and placement of statements. It provides examples and explanations of each concept. The document is authored by Mr. Orestes Mendoza and covers fundamental programming topics.

Uploaded by

Orestes Mendoza
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Topics

Assignment Operations Formatting Numbers for Program Output Using Mathematical Library Functions Program Input Using the cin Object Symbolic Constants

Mr. Orestes Mendoza

Assignment Operations
Assignment statement is the most fundamental C++ statements for both passing on values to variables and performing computations. variable = expression; base = 25; height = 18; a = b = c = 25;
Mr. Orestes Mendoza

Coercion
Coercion is referred to conversion of data type from one type to another. int a; float b;

a = 5.46; // value is converter to integer (5) b = 43; // value is converted to float (43.0)

Mr. Orestes Mendoza

Assignment Variations
Accumulating
variable = variable + otherVariable

Counting
variable = variable + fixedNumber

Mr. Orestes Mendoza

Formatting Numbers for Program Output (iomanip)


Manipulator setw(n) setprecision(n) showpoint fixed Action Set the field width to n Set the floating point precision to n places. Always display 6 digits in total Always display that decimal point

Mr. Orestes Mendoza

Mathematical Library Functions (cmath)


abs(a) pow(a1, a2) sqrt(a)

Mr. Orestes Mendoza

Program Input Using the cin Object


The cin object is used for data input. cin >> variable;

Mr. Orestes Mendoza

Symbolic Constant
A symbolic constant is name that substitute a sequence of character that cannot be changed.
numeric constant character constant string.

const double PI = 3.1416; const int MAXIMUM = 85;

Mr. Orestes Mendoza

Placement of Statements
The general rule in C++ for variable or symbolic constant must be declared before it can be used.
preprocessor directives int main() { symbolic constants variable declarations other executable statements return value }

Mr. Orestes Mendoza

You might also like