0
Parts of a Loop
for(condition) { body } So my question is what is the proper term for the (condition). I know that inside the condition you may include the three arguments, but is there a proper term for what those arguments are inside of?
7 ответов
+ 3
for(initial variable(s); test expression; update expression)
{
//body
}
Example of initial variable - int a = 2, or a (Some previously declared a).
Example of test expression - a<77, or a!=6.
Example of update expression - a++, or a-=3.
Simple example:
for(int i=0;i<10;i++)
{
//Do something 10 times!
}
The update expression can be anything in general, not just increment or decrement.
A weird example:
for(int i=0;i!=5;cin>>i)
{
//Run the loop till i reads 5.
}
+ 3
@Lithia
Sorry, I misunderstood your question.
After all, that is what the first thing that comes to mind when you see 'Parts of a loop'.
The parenthesis have no such special name. They can be called 'the function call operator',but I prefer to simply call them function parenthesis.
+ 2
for(initialization;condition;increment/decrement)
{
}
+ 2
I wasn't asking for what the arguments are called or what they do, but thank you for your answers. I was trying to ask what the () is called, and I've found that it is called the function call operator. Thank you @Kinshuk for your last example, I didn't know you could do that.
0
Lithia ..Can i ask something else.. if u dont mind, that how many header files do we have?... Only in C++
0
Abuzar Barki for that kind of thing you have to Google search https://en.cppreference.com/w/cpp/header
0
Ok dear.. thanks for giving me so much time..