I have to say that code is a stunning mixture of C and C++, with some major conceptual problems.
|Our teacher wanted in assembly language.... |
So how were you planning to go from this code to assembly? Especially the C++ part? Please tell me you weren't going to get the compiler to produce the assembly?
|..... and I am very new to this so I am not sure if this is right.|
Teachers provide enough info for students to do the assignments, so if you don't know what you are doing to this extent, what might be the reason for that?
Don't name one of your own functions the same as those found in a library, that you include a header for. Normally one would declare the functions before main, and put the definitions after main. Apparently you didn't get a compilation error for not doing this because
is in <stdlib.h>
The main() function is C code, and you provide the right number of arguments for stdlib
. Although you didn't check the return value of the scanf, so presumably you are going to pray that it works?
Then, BAM , you define your own
function with C++, but it only takes 1 argument !!
alluded to, if you compiled with a C compiler, it falls over because it doesn't recognise C++.
Even if you used a C++ compiler there are still problems:
does not handle
So a major re think needed - I would advise actually going to your Lectures & Tutorials, and realise when they ask for assembly code - then do that, don't write in another language.
EDIT: There are several other problems I didn't bother to mention.