Writing a program that adds two numbers together may seem like a trivial task. We obviously need to declare three variables, two to hold values of the numbers to be added, known as addends, and another to hold the sum. The following recipe illustrates some problems that arise due to word length.
The following steps demonstrate how to perform arithmetic operations:
Create a new folder and name it
addTwoNums_c3v0
. Invoke uVision5 and create a new project namedaddTwoNums
within this folder.Use the RTE manager to select the MCBSTM32F400 evaluation board and configure it as we did for
helloWorld_c2v0
, from the Writing to console Window recipe in Chapter 2, C Language Programming.Copy the files,
Serial.c
,Serial.h
, andRetarget.c
, from thehelloWorld_c2v0
recipe into the folder.Create a new source file named
addTwoNums.c
and enter the following program. Please note that we're using the folding editor feature to omit boilerplate code:/**************...