Sunteți pe pagina 1din 5

#include functions.

h #include iostream using namespace std; int main(){ function 1 - finished prints rectangle printBoard(1,1); - pass cout endl; printBoard(2,2); - pass cout endl; printBoard(3,2); - pass cout endl; printBoard(2,3); - pass cout endl; ----------------------function 2 - finished prints right triangle printRight(3); - pass cout endl; printRight(4); - pass cout endl; printRight(5); - pass cout endl; printRight(8); - pass cout endl; -----------------------function 3 - done prints right justified triangle printRight_rightJustified(3); cout endl; printRight_rightJustified(4); cout endl; printRight_rightJustified(5); cout endl; printRight_rightJustified(9); cout endl; -------------------------- pass - pass - pass - pass

funtion 4 - done prints right justified upside down triangle printRight_upsideDown_rightJustified(2); - pass cout endl; printRight_upsideDown_rightJustified(3); - pass cout endl; printRight_upsideDown_rightJustified(5); - pass cout endl; printRight_upsideDown_rightJustified(10); - pass cout endl; ---------------------------function 5 - done

prints right upside down triangle printRight_upsideDown(1); - pass cout endl; printRight_upsideDown(3); - pass cout endl; printRight_upsideDown(5); - pass cout endl; printRight_upsideDown(8); - pass cout endl; ------------------------------function 6 prints a series of values threeSeries (2); - pass cout endl; threeSeries (6); - pass cout endl; threeSeries (4); - pass cout endl; threeSeries (11); - pass cout endl; ---------------------------------function 7 swaps the values x , y int x, y; x = -5; y = -5; swap(x,y); - pass cout x y; cout endl; y = -7; swap(x,y); - pass cout x y; cout endl; x = 8; y = 12; swap(x,y); - pass cout x y; cout endl; x = 0; y = 0; swap(x,y); - pass cout x y; cout endl; --------------------------function 8 prints true if second variable is within first false otherwise cout cout cout cout cout cout equalsDigit(59, 9); endl; equalsDigit(95, 5); endl; equalsDigit(46, 5); endl;

cout equalsDigit(101, 0); cout endl; ------------------------function 9 runs the range of numbers from start to end inclusive if (end start), it will swap start and end prints the number if any digit of the number is the same as 'digit' printIfHoldsDigit(7,1,0); cout endl; printIfHoldsDigit(9,17,9); cout endl; printIfHoldsDigit(19,4,5); cout endl; printIfHoldsDigit(6,11,2); cout endl; ----------------------------function 10 reverses the order of the numbers cout reverseNumber(123); cout endl; cout reverseNumber(1234); cout endl; cout reverseNumber(4231); cout endl; cout reverseNumber(1020501); cout endl; ------------------------------function 11 alters n to be the new variable int n = 50; reverseNum(n); cout n endl; n = 158; reverseNum(n); cout n endl; n = 1911; reverseNum(n); cout n endl; -------------------------------function 12 prints how many hundreds in val i.e. 1325 prints 13 cout calcNum(1); cout endl; cout calcNum(123); cout endl; cout calcNum(1234); cout endl; cout calcNum(12300); cout endl; ----------------------------

function 13 prints a sales chart printBarChart(15, 763, 232, 11, 633); cout endl; cout endl; printBarChart(133, 304, 736, 853, 456); cout endl; cout endl; printBarChart(1252, 350, 903, 2, 83); cout endl; cout endl; printBarChart(134, 704, 434, 853, 234); cout endl; cout endl; ------------------------function 14 Prints 1 if Prime 0 otherwise cout isPrime(1); cout endl; cout isPrime(2); cout endl; cout isPrime(3); cout endl; cout isPrime(10); cout endl; -------------------------function 15 prints string of primes between first and second printPrimes(1,20); cout endl; printPrimes(20,1); cout endl; printPrimes(1,1); cout endl; printPrimes(21,22); cout endl; ------------------------function 16 same as above, but prints 5 per line prettyPrintPrimes(1,20); cout endl; cout ---------------------------; cout endl; prettyPrintPrimes(20,1); cout endl; cout ---------------------------; cout endl; prettyPrintPrimes(1,101); cout endl; -------------------------------------

function 17 returns the sum of the first 'n' primes cout sumPrimes(5); cout endl; cout This first one should = 28; cout endl endl; cout sumPrimes(8); cout endl endl; cout sumPrimes(82); -----------------------------------function 18 prints twin primes between first and second int printTwinPrimes(1,20); cout endl; cout According to functions.h this should be endl (3, 5) (5, 7) (11, 13) (17, 19) endl; cout endl; printTwinPrimes(20,232); cout endl; -------------------------------function 19 prints cousin primes (prime pair with difference 4) printCousinPrimes(1,25); cout endl; cout According to functions.h this prints endl (3, 7) (7, 11) (13, 17) (19, 23) endl; cout endl; printCousinPrimes(25,80); cout endl; -------------------------------function 20 prints an equilateral triangle printEquilateral(1); cout endl endl; printEquilateral(2); cout endl endl; printEquilateral(3); cout endl endl; printEquilateral(6); cout endl endl; -------------------------------------

return 0; }

S-ar putea să vă placă și