

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


/* 1 / / Sample code for slicing exercise. v. 2/21/05 / / 2 / #include <iostream.h> / 3 / void main() / 4 / { / 5 / const int reps=10; / 6 / int i; / 7 / int a, b, c, d; / 8 / cin >> a; / 9 / cin >> b; / 10 / / 11 / c = 2a + ab; / 12 / d = 3a + b; /* 13 / for ( i=0; i<= reps; i++ ) / 14 / { / 15 / if ( c < 0 ) / 16 / { / 17 / a = 2a; /* 18 / c = c+5; / 19 / } / 20 / else / 21 / { / 22 / c = 2a + ab; / 23 / d = 3a + b; /* 24 / } / 25 / } / 26 / cout << c << endl; / 27 */ }