Parts of a Loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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?

21st Oct 2017, 2:54 AM
Lithia
Lithia - avatar
7 Answers
+ 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. }
21st Oct 2017, 4:00 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 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.
22nd Oct 2017, 3:14 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
for(initialization;condition;increment/decrement) { }
21st Oct 2017, 5:38 AM
Nanda Balakrishnan
+ 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.
21st Oct 2017, 8:47 PM
Lithia
Lithia - avatar
0
Lithia ..Can i ask something else.. if u dont mind, that how many header files do we have?... Only in C++
12th Dec 2019, 1:06 PM
Abuzar Barki
Abuzar Barki - avatar
0
Abuzar Barki for that kind of thing you have to Google search https://en.cppreference.com/w/cpp/header
12th Dec 2019, 4:06 PM
Lithia
Lithia - avatar
0
Ok dear.. thanks for giving me so much time..
12th Dec 2019, 4:18 PM
Abuzar Barki
Abuzar Barki - avatar