Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
int i,sum;
Variable i is declared here as it is used in all loops. variable sum is used in third loop. Both these variables can be declared in respective loops also.
for(i=10; i>6; i=i-2) cout<<i<<” “;
This one run 2 times value of i as 10 and i as 8 .
for(i=-5; i> -8; i–) cout<<i+1<<” “;
This loop runs 3 times for -5, -6 and -7 but prints one higher value as -4,-5 and -6
for(i=-3,sum=0; i<3; i++) cout<<sum++<<” “;
This loop runs 6 times for -3,-2,-1,0,1,2 and prints sum starting from 0 to 5 .
Common Errors
Always watch for correct loop count and respective value changes by dry running the loop.