Can see how that works right there so I could create as many of these students as I want and this is what’s cool about structs is I can just define the basic template for a student in my program and then I can create individual students down here that I can work with so now I have this like student variable.
Here I could do whatever I want with.
It I could pass it into a function I could print it out onto the screen I could use it in something like an if statement I could do basically anything I want with it it’s it acts a lot like a variable or an array so remember variables and arrays or just containers we can do just about anything we want with them.
And that’s the same with a struct so this has just been kind of an.
Introduction and what you could do as an exercise is think.
Of other things you might want to model in your program so maybe something like a book or something like a phone you could model a phone using a struck basically any type of information you could store using a struct just like this in this.
Tutorial I want to talk to you guys about while loops in C now a while loop is basically a structure in the C programming language that we can use to loop over and continually execute.
A specific block of code until a certain.
Condition is false so I can specify a condition.
And then I can basically just loop over a bunch of code until that condition is no longer true.
And loops can be really useful there’s a lot of times in our programs or we’re gonna want to let continually do something while something else is.
True or while a certain condition is met and I’m gonna show you guys a really basic while loop in this tutorial and then in the next tutorial we’re actually gonna build a really cool guessing game using while loops so it should be pretty fun and you should get a pretty good idea of like how these things work the.
I want to do and this isn’t directly related to creating a while loop.
Though is I want to create an integer so I’m just gonna create an integer called index and I’m gonna set it equal to 1 now what I want to do.
Is I want to actually create a while loop and you guys will see where this index comes into play so in order to create a while loop I can just type out while and open and close parentheses and then an open and close curly bracket and this is basically like the outline sort of like the template for our while loop basically how this is gonna work is up here.
In these parentheses I’m gonna specify a condition and as long as that condition is true I’m gonna loop through all of the code inside of these curly brackets so inside of these curly brackets I’m gonna put a bunch of code and as long as the condition in these parentheses is true I’m gonna execute all that code so up here we’re going to specify.
A condition I’m gonna specify a condition that index is less than or equal to 5 so while index is less than or equal to 5 I want to execute all the code inside of here so I’m gonna put some code in here the first thing I’m going to do.
Is I’m just gonna print out the value of index so over here I’m just gonna say we’re.