C Programming Tutorial - 1 - Introduction
thenewboston
Bucky Roberts explains how to code in C programming one of the most popular programming languages in the entire world. C is used to make any software on your desktop like all of these programs you can make. You can pretty much use it to program any electronic like robots vending machines stoplights your microwave could be programmed and C so it 's basically a very widely used programming language. What this what we 're going to do right here is we're going to download a piece of software and it 's actually completely free which is freaking awesome. This one program has every single thing that you need and like I said free how awesome is that so go to downloads right here and it says ok you have to choose a couple of options the binary release the source code or source code from
the SVN.
C Programming Tutorial - 2 - Setting Up Code Blocks
thenewboston
The first thing I actually want to do is minimize that and well I can click Next finish out of that and I want to make a folder on my desktop so new folder and this is where I 'm gon na be putting all of my project files so I'm gon na put C underscore tutorials tutorials. This is actually a very simple program now I know you guys don't know what any of this means right now but I do want to show you guys how to run the program whenever you 're ready so we can actually run this right now by clicking this little button it 's called a build and run and it takes actually a couple of steps to run your program the first one is to compile it or build it pretty much take all of this code the words that we understand in the translation translates it to once and zeros. The last thing I want to mention is in these tutorials I 'm gon na be typing a whole bunch of source code and if you guys just want to like sit back and watch it swirls and then get the source code later on I'm going to post it on my website so if you go to my website Bucky 's room org. and if. you click forum then in the c-section section get it anyways if you just click that right there then of course my source code isn't posted right now.
C Programming Tutorial - 3 - How Computer Programs Work
thenewboston
Understanding Computer Programs
Welcome back to another tutorial! Before we start coding, let's understand how a computer program works. A computer program is made up of functions, which tell the computer what to do. For example, let's say we want to create a program that watches a YouTube video for us. Here are the functions it would need:
· Move the mouse to the Google Chrome icon.
· Click.
· Click on videos.
· Play a video.
As you can see, a computer program is made up of these functions. One important function that every C program needs is called "main". It is the starting point of the program. The main function is enclosed in curly brackets, and each line inside it is an instruction. Instructions end with a semicolon.
When you run a program, the computer automatically looks for the main function. It then executes the instructions inside it. In our example, the program would print "Hello World" on the screen. The line "return 0" indicates that the function ran correctly.
The "include" lines in our program tell the computer to include built-in functions that we can use. These functions allow us to print text on the screen, among other things.
Blank lines, indents, and whitespace do not affect the program's functionality. They are used to make the code more readable.
C Programming Tutorial - 4 - Print Text on the Screen
thenewboston
In this world I 'm going to be telling you guys how to do a very simple command and that 's just print stuff out on the screen. So of course go ahead and delete this right here and give yourself some room to work with I like having a blank line above and below makes it stand out especially whenever. I'm teaching. slash a actually makes a sound on your computer. slash t and that just makes it tab so says Bucky is awesome tab tab tab. slash a is short for alert it pretty much says play your computer's alarm alert or beef noise so actually run this code in your compiler and you guys can hear what your computer sounds like..
C Programming Tutorial - 5 - Comments
thenewboston
Introduction
Sorry for the interruption, my family came over because of a village-wide garage sale. Now, let's continue learning about printing on the screen. Our program currently prints something, beeps, and then prints again. Although it appears to happen simultaneously, it actually happens sequentially. I also want to explain comments, which are notes you can put in your program. When the computer encounters a comment, it ignores it. These comments are useful for reminders or for collaborating with other programmers.
Multi-line Comments
To create a comment that spans multiple lines, you can use the /* and */ symbols. Anything between these symbols will be treated as a comment. For example:
/*This is my program.It prints out my name.It's awesome!*/
These comments are typically used above functions or at the top of the program to explain their purpose.
Single-line Comments
If you want to leave a short comment on a single line, you can use two forward slashes (//). Anything after the slashes will be ignored by the computer. For example:
// These are the lines that print my name
When you build and run the program, the comments are removed and do not affect the program's functionality.
Next Steps
In the next lesson, I will discuss conversion characters and how they can improve the printf statement. Stay tuned!
C Programming Tutorial - 6 - Conversion Characters
thenewboston
Alright guys, now that we understand the basics of how to print on the screen, I want to talk to you about how to make the print command more powerful using conversion characters.
In C programs, we can work with different data types such as numbers, text, and strings. Strings are basically a group of characters or words.
Let's make another printf statement that uses conversion characters. The special symbol we'll use is %s, which is a placeholder for a string. After the first quotation mark, we can add another string to substitute in that place.
For example, we can say "%s is the best person ever" and substitute the string "Bucky" in that place. You can use as many conversion characters as you want in a printf statement.
Similarly, we can use %d as a placeholder for a whole number or integer. We can input a number like 9 and say "I ate %d corn dogs last night".
For numbers with decimal places, we use %f as a placeholder. By default, it shows six decimal places. But we can format it to show a specific number of decimal places by adding a number after the %f, like %0.2f for two decimal places.
So, for example, we can say "pi is %f" and display it to two decimal places. We can also show it to four decimal places by using %0.4f.
Conversion characters are useful for customizing programs and allowing user input. Later on, I'll show you how to get user input.
No comments:
Post a Comment