Printf() ๐จ๏ธ#
printf()
is a function that can output or print text. A function is a piece of code that runs a set of code to do something.
Note
Functions will be covered in-depth in a later chapter.
To use this function, you have to write printf()
with a string inside of the parentheses.
Ex.
printf("print me!");
printf("some string");
printf("a really really really long string");
Recall
A string is some text surrounded by double-quotes. See Strings ๐งต for more details.
Tasks ๐ฏ#
Print the following text to the output:
My name is Bob!
Solution โ
#include <stdio.h> int main() { printf("My name is Bob!"); return 0; }
Print the same text as before to the output except use a print statement for each word:
My name is Bob!
Solution โ
#include <stdio.h> int main() { printf("My "); printf("name "); printf("is "); printf("Bob! "); return 0; }