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.
If we watch the series 1 8 27 64 125 carefully we will see that it is a cube series of natural numbers. Now the code shall be built as follows.
int tbase=1; //The base number we initialise as 1 which we will increment inside the loop int term; //This variable is to print the term for(int tc=1;tc<=15;++tc) //This loop begins at one and goes up to term count required. { term=tbase*tbase*tbase; //Here the base value shall be cubed and the term will be deduced.
cout<<term<<” “; //Term shall be printed here.
tbase++; //The new term base will be prepared here. }
Notes
Generic method of series building can be used in such examples. Focus should be deducting the right formula.