C Language for Beginners Tutorial- Basic Output Function Printf()

preview_player
Показать описание
In this C Language for Beginners Tutorial we go over the basics output of the function printf().

Remember that printf is a function even though it doesn't seem like that because it is built into the stdio.h library.

Remember, to always include stdio.h when using the printf function in c. You will always include this because that is how you are going to display your program.

I started off by making a simple "hello, world!" string display on the screen. Nothing fancy, but it shows you that to remember to put the string in quotes when you are passing it to printf.

You also see me using the \n in the program. This represents a new line. When you don't include this, you will have the $ appear after the cursor.

After I displayed the string I made a function called print_string that did the same thing just in a different way using printf. Declare the function above main if you made the function below main. If you made it above main then you don't have to worry about it.

I also used printf using different data types. The first one was int meaning integers and when you want to display that in printf you need to use %d or you can use %i and then put a comma and then passing the name of the variable to the printf function.

I did the same thing for another data type, a float. I used the %.2f in some of my examples in the video. If you don't include this then you will get more decimal place numbers. The .2 will only display two numbers after the placeholder.

I did the same thing for another data type in the c programming language, a character, or you can represent a character in your program by using the char keyword.

There is a lot you can do with printf. You can pass strings, you can do math expressions in printf. There are a lot of things you can do with it but printf mainly displays your program.

Thanks for watching and remember to like, share, and subscribe.
Рекомендации по теме
Комментарии
Автор

If you have any questions about printf leave them here and I'll answer them 😀

chrismatthew
visit shbcf.ru