Compare & append

I need to write a Shell Script to compare two files & display the result. If the two files are different append them and store them in a new file. How do i proceed...can someone give me a coding ?

diff file1 file2
if [[ $? -ne 0 ]]
cat file1 file2> newfile
fi

you can use cmp to compare the two files.

cmp file1 file2

Thanks ! the replies were useful ! I could build upon it !