printf()
The printf() function prints the characters and returns the number of character printed, the format is a string starting with % and ends with conversion character (like c, i, f, d, etc.).
Syntax : printf(template, variables)
Parameters :
- template : string to be written on the console, it also contains format specifiers like %d, %s etc
- variables : values that will replace the format specifiers
Types of Format Specifiers :
- %d : used for integers
- %f : used for floating point values
- %s : used for strings
Returns : number of characters printed
Example :
MATLAB
% using printf() without format specifiers printf( "Hello World!!\n" ); x = 5; % using printf() with format specifiers printf( "Welcome, value of x is %d\n" , x); |
Output :
Hello World!! Welcome, value of x is 5
How to output in Octave GNU
Octave is open-source, free available for many of the platforms. It is a high-level language. It comes up with a text interface along with an experimental graphical interface. It is also used for various Machine Learning algorithms for solving various numeric problems. You can say that it is similar to MATLAB but slower than MATLAB.
There are multiple library functions to display an output in Octave.