This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ember, only ‘assignment’
statements require the semicolon.
Education Example fprintf (output) syntax
General Form: fprintf ( ‘ format ’ , Var)
Where format contains text and a format field (%f or
%s) for each variable to be output
fprintf(' \n Surface area is %f square inches.\n ' , SA) ‘Carriage’ Return
to start printing
a new line Location within
for a number
to be printed Register
to be printed Result:
Surface area is 54.3400 square inches.
>> % notice the output units are included in the format statement
in this example they are not a variable in this example.
Education Output Syntax
General Form: fprintf ( ‘ format ’ , Var1, Var2, Var3)
To output more than one variable you can use multiple fprintf
statements (one for each variable)
or you can output more than one variable with a single fprintf
You can also control the number of decimal places printed. fprintf(‘\n Alpha = %6.2f %s and Beta = %.3f %s\n’,...
View Full Document
This note was uploaded on 01/28/2014 for the course ENGE 1114 taught by Professor Twknott during the Spring '06 term at Virginia Tech.
- Spring '06