

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!


Exercise 1 We want to pack N eggs in NB boxes of 12 eggs each. Determine, without using any division, the number NB of boxes (completely filled, to be sealed), as well as the remaining number of free eggs (the division will be simulated by successive subtractions). Answer #include
int main() { const int n =10; int a[n]= {5,9,-4,0,3,7,-2,6,1,4}; cout<<"Before permutation the array was: "<<endl; for(int i=0;i<n;i++) cout<<a[i]<<" "; int first_elt = a[0]; for(int i=0; i<n-1;i++) a[i]=a[i+1]; a[n-1] = first_elt; cout<<"\nAfter permutation the array is: "<<endl; for(int i=0;i<n;i++) cout<<a[i]<<" "; return 0; } Exercise 3 Write a function that display a number entered by the user if it’s EVEN or ODD Answer include