#WSQ08 Functions Beach

Hey so for this new assigment we had to do Fun With Numbers again, but this time we needed to create a function before we asked the user for the numbers; therefore the structureyou must follow is:

int add (int a, int b)
{
    int s;
    s=a+b;
    return s;
}

That’s the main structure for each function, you must do this for the substraction, division, and integer division, remember to change the letter or name for each function though.

Screenshot7.1.png

Then you can proceed to begin with the main program, where you’d be asking for the numbers who will be used  :

int main ()
{
int a, b, s, r, m, d, i;
cout<< “Give me a integer number” << endl;
cin>>a;
cout<< “Give me second integer number” << endl;
cin>>b;

Screenshot7.2.png

There you can see that we choose our functions created before, and showing that the integers which are going to be use are the ones choosen before; finally we print the answers using “cout” finally ending with the return 0; “

Heres is my code, in case you need it

 

 

CC BY-SA 4.0 #WSQ08 Functions Beach by canadamike17 is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.