Day 12
Hello.
Today I learned the for loop
It is used to repeat the command instead of writing it for several lines and it is very famous to the point that when the programmer thinks about repeating the command the first thing that comes to his mind is the for loop which is like do while and while loop which we wrote about before
Here is the code that we will explain in detail
In line 8 as we know we defined the grade and sum to store the values in them
Line 9 we started in today's command and wrote for and then we started writing the conditions aaaaand the first thing we wrote counter and started from 1 and secondly we gave a command that as long as the counter is still less than or equal to 6 then the next command is repeated again and finally we gave the counter++ command which adds 1 each time to the counter.
In line 11 we print for the user to enter the student's first grade
Line 12 is responsible for entering the grade and keeping it in int grade
Line 13 is responsible for adding the two variables sum and greade together
Finally, in line 16, it prints the average of degrees
Thus, we learned how to make a program to calculate the average of grades
تعليقات
إرسال تعليق