- The main program:
/*****************************************************************/
/* Programmer: Dan Bennett */
/* Program: Homework 2, area under the curve */
/* This program finds the area under the curve of a fourth */
/* degree polynomial. */
/*****************************************************************/
#include <iostream>
// other includes
int ACONSTENT=4;
float fofx(float x, float a, float b, float c );
// other function prototypes
main () {
int avaraible;
code
}
float fofx(float x, float a, float b, float c) {
float ret;
ret = a*x*x+b*x+c;
return(ret);
code
}
- The main routine
main () {
}
- types
- int
- bool
- float, double
- char
- Operators
- +,-,/,*,%
- ==, <= != ...
- ++, +=, -= ...
- strings
- #include <string>
- +
- .length
- .size
- string::size_type lengthvar
- lenghtvar = astring.length()
- pos = astring.find(string)
- newstring = astring.substr(starpos,endpos)
- input/output
- cin
- cout
- endl, '/n'
- <iostream>
- <iomanip>
- setw(n)
- setprecision(n)
- cin.get(char)
- cin.ignore(count,char)
- getine(cin,string)
- if
if (condition) {
statements
} else {
statements
}
- for
for(init_statement; condition; increment statement) {
statements;
}
- While
while ( condition) {
statements
}
- do
do {
statements
} while (condition)
- Case statement
switch (var) {
case val1:
statements;
break
case val2:
case val3:
statements;
break;
default:
statements;
}
- Functions
type funname ( [const] vartype [&] varname, ...) {
statements;
}