This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Find output of the following program?
void main()
{
int a,b;
for(a=1,b=1;a<5,b<10;b++)
cout<<a;
}
Option C
Here, the important point is the comma operator used in the for-loop condition.
for(a=1,b=1; a<5,b<10; b++)
cout << a;
In a for loop, the condition part can use the comma operator (,). When the comma operator is used, all expressions are evaluated, but the result of the last expression decides the loop condition.
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.