example program to print out "Hello World!" to the terminal
Homepage
Description¶
This example is to demonstrate printing "Hello World!" to the command line. The printf statement can be very useful for debugging.
Examples¶
%c is used to print characters
// initialize some characters
char x = 'a';
char y = 'b';
char z = 'c'
// print characters to terminal
printf("characters: %c,%c,%c",x,y,z); // would print 'characters: a,b,c'
%d is used to print integers
// initialize integer with value 42
int x = 42;
printf("The answer is %d",x); // would print 'The answer is 42'
%f is used to print floating point numbers
// initialize pie with value 3.14
float pie = 3.14;
printf("pie = %f ",pie); // would print 'p = 3.14'