Computer Science - Object Oriented Programming Using C++ - Discussion

Discussion Forum : Object Oriented Programming Using C++ - Section 7 (Q.No. 1)
1.
The comma operator (,) is primarily used in conjunction with
'for' statement
'if-else' statement
'do-while' statement
All of the above
None of the above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
10 comments Page 1 of 1.

Digvijay Khot said:   2 years ago
@All.

No,It should be like;

for(initialisation ; condition ; increment)
{
statement(s);
}

so, the ans should be E) none.

Nikhil Sharma said:   3 years ago
Thanks for clearing it @Ayesha.

Ayesha... said:   4 years ago
The syntax for running two variable for loop simultaneously.

for (i = 0, j = 0; i < n, j < n; i++, j += 5)

Ayesha Ran said:   4 years ago
The correct syntax for running two variable for loop simultaneously.


for (i = 0; i < n; i++)
for (j = 0; j < n; j += 5)

Running two variable for loop simultaneously. Using Comma;
for (i = 0, j = 0; i < n, j < n; i++, j += 5)

So, the answer is A.

Kathirvel said:   8 years ago
This question is very useful, Thank you.

Shubham Shrivastava said:   8 years ago
No option A is wrong because in for loop we use semicolon(;).

Arun said:   8 years ago
Yes because we use semicolon (;) in for loop. Its right and A answer is wrong.

Waqas said:   9 years ago
No it's not true because,

for(init; condition; increment)
{
statement(s);
}

User42 said:   1 decade ago
Umm no it's not and this question needs updated because E is the correct answer. A for loop separates its arguments using a semi-colon, not a comma.

Shivam said:   1 decade ago
As we know that syntax of for loop:

for(__,__,__)
{
}

Post your comments here:

Your comments will be displayed after verification.