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!
Related codes are those codes where similar programming concepts are in use. They are different from alternate codes in the sense that they may not have same purpose and results.
int t=13; //The beginning number is declared in t and set equal to 13 as given in problem.
for(int tc=1;tc<=20;++tc)
The loop starts from 1 and goes upto 20 the term count given.
cout<<t<<” “; The term is printed.
t+=2;
The next term is prepared by adding 2 to the previous number.
Notes
Notice that the index of loop and the term value calculation are being done in separate variables. This is the ideal approach for series printing questions.
Common Errors
If the term counting loop begins fro 0 then the condition check would be only < operator else if it begins from 1 the condition check would be <= operator. Students are advised to take additional care for such operators.