loop constructs
classification based on placement of a loop is a construct that
condition executes the statement repeadedly for a
certain number of times until condition is
satisfied
Variable iteration
fixed iteration
Do while loop
for loop While loop
exit controlled loop
for(intialvalue,final value ,step value) will continue atleast once
Entry controlledloop
Executes the statement repeatedly till i f the condition is not satisfied
the condition is satisfied will not execute
Post tested loop
for loop is also entry controlled loop if the condition
is not satisfy
pre-testedloop
Classification based
on finiteness
finite loop(fixed
number of infinite loop(unfixed
iteration) number of itertion)
Continuous loop step loop While loop
Do while loop
3
4
5 Iterative constructs in Java
6 (a) 1, 4, 9, 16 …………………………
7 //Program to display the first ten numbers
8 public class display
9 {
10 public static void main(String args[])
11 {
12 int i;
13 for(i=1;i<=10;i++)
14 [Link](i*i);
15 }
16 }
17 (b) 1, 2, 4, 7, 11 ………………………
18 //Program to display the first ten numbers
19 public class display1
20 {
21 public static void main(String args[])
22 {
23 int i,j=1;
24 for(i=1;i<=10;i++)
25 {
26 [Link](j+" ");
27 j+=i;
28 }
29 }
30 }
31 (c) 3, 6, 9, 12 …………………………
32 //Program to display the first ten numbers
33 public class display2
34 {
35 public static void main(String args[])
36 {
37 int i;
38 for(i=3;i<=30;i+=3)
39 [Link](i);
40 }
41 }
42 (d) 4, 8, 16 ,32 ……………………………
43 //Program to display the first ten numbers
44 public class display3
45 {
46 public static void main(String args[])
47 {
48 int i,j=4;
49 for(i=1;i<=10;i++)
50 {
51 [Link](j);
52 j*=2;
53 }
54 }
55 }
56 (e) 1.5, 3.0, 4.5, 6.0 ……………………………
57 //Program to display the first ten numbers
58 public class display4
59 {
60 public static void main(String args[])
61 {
62 double i,j=1;
63 for(i=1;i<=10;i++)
64 {
65 [Link](j);
66 j=1.5*i;
67 }
68 }
69 }
70 (f) 0, 7, 26 ………………………………
71 //Program to display the first ten numbers
72 public class display5
73 {
74 public static void main(String args[])
75 {
76 int i;
77 for(i=1;i<=10;i++)
78 [Link](i*i*i-1);
79 }
80 }
81 (g) 1, 9, 25, 49 ………………………………
82 //Program to display the first ten numbers
83 public class display6
84 {
85 public static void main(String args[])
86 {
87 int i;
88 for(i=1;i<=20;i+=2)
89 [Link](i*i);
90 }
91 }
92 (h) 4, 16, 36, 64 ……………………………
93 //Program to display the first ten numbers
94 public class display7
95 {
96 public static void main(String args[])
97 {
98 int i;
99 for(i=2;i<=20;i+=2)
100 [Link](i*i);
101 }
102 }
103 (i) 0, 3, 8, 15 …………………………………..
104 //Program to display the first ten numbers
105 public class display8
106 {
107 public static void main(String args[])
108 {
109 int i;
110 for(i=1;i<=10;i++)
111 [Link](i*i-1);
112 }
113 }
114 (j) 24, 99, 224, 399 ………………………………….
115 //Program to display the first ten numbers
116 public class display9
117 {
118 public static void main(String args[])
119 {
120 int i,j=1;
121 for(i=1;i<=10;i++)
122 {
123 [Link](j*j-1);
124 j=i*5;
125 }
126 }
127 }
128 (k) 2, 5, 10, 17 ……………………………………..
129 //Program to display the first ten numbers
130 public class display10
131 {
132 public static void main(String args[])
133 {
134 int i;
135 for(i=1;i<=10;i++)
136 [Link](i*i+1);
137 }
138 }
139
140 //(a) 1, 4, 9, 16 …………………………
141 //Program to display the first ten numbers
142 public class display_while
143 {
144 public static void main(String args[])
145 {
146 int i,j;i=1;
147 while(i<=10)
148 {
149 j=i*i;
150 [Link](j);
151 i++;
152 }
153 }
154 }
155 // (b) 1, 2, 4, 7, 11 ………………………
156 //Program to display the first ten numbers
157 public class display_while1
158 {
159 public static void main(String args[])
160 {
161 int i,j=1;i=1;
162 while(i<=10)
163 {
164 [Link](j+" ");
165 j+=i;
166 i++;
167 }
168 }
169 }
170 //(c) 3, 6, 9, 12 …………………………
171 //Program to display the first ten numbers
172 public class display_while2
173 {
174 public static void main(String args[])
175 {
176 int i;i=3;
177 while(i<=30)
178 {
179 [Link](i);
180 i+=3;
181 }
182 }
183 }
184 //(d) 4, 8, 16 ,32 ……………………………
185 //Program to display the first ten numbers
186 public class display_while3
187 {
188 public static void main(String args[])
189 {
190 int i,j=4;i=1;
191 while(i<=10)
192 {
193 [Link](j);
194 j*=2;
195 i++;
196 }
197 }
198 }
199 //(e) 1.5, 3.0, 4.5, 6.0 ……………………………
200 //Program to display the first ten numbers
201 public class display_while4
202 {
203 public static void main(String args[])
204 {
205 double i,j=1;i=1;
206 while(i<=10)
207 {
208 [Link](j);
209 j=1.5*i;
210 i++;
211 }
212 }
213 }
214 //(f) 0, 7, 26 ………………………………
215 //Program to display the first ten numbers
216 public class display_while5
217 {
218 public static void main(String args[])
219 {
220 int i;i=1;
221 while(i<=10)
222 {
223 [Link](i*i*i-1);
224 i++;
225 }
226 }
227 }
228 //(g) 1, 9, 25, 49 ………………………………
229 //Program to display the first ten numbers
230 public class display_while6
231 {
232 public static void main(String args[])
233 {
234 int i;i=1;
235 while(i<=20)
236 {
237 [Link](i*i);
238 i+=2;
239 }
240 }
241 }
242 //(h) 4, 16, 36, 64 ……………………………
243 //Program to display the first ten numbers
244 public class display_while7
245 {
246 public static void main(String args[])
247 {
248 int i;i=2;
249 while(i<=20)
250 {
251 [Link](i*i);
252 i+=2;
253 }
254 }
255 }
256 //(i) 0, 3, 8, 15 …………………………………..
257 //Program to display the first ten numbers
258 public class display_while8
259 {
260 public static void main(String args[])
261 {
262 int i;i=1;
263 while(i<=10)
264 {
265 [Link](i*i-1);
266 i++;
267 }
268 }
269 }
270 //(j) 24, 99, 224, 399 ………………………………….
271 //Program to display the first ten numbers
272 public class display_while9
273 {
274 public static void main(String args[])
275 {
276 int i,j=1;i=1;
277 while(i<=10)
278 {
279 [Link](j*j-1);
280 j=i*5;
281 i++;
282 }
283 }
284 }
285 //(k) 2, 5, 10, 17 ……………………………………..
286 //Program to display the first ten numbers
287 public class display_while10
288 {
289 public static void main(String args[])
290 {
291 int i;i=1;
292 while(i<=10)
293 {
294 [Link](i*i+1);
295 i++;
296 }
297 }
298 }
299 //(a) 1, 4, 9, 16 …………………………
300 //Program to display the first ten numbers
301 public class display_do_while
302 {
303 public static void main(String args[])
304 {
305 int i,j;i=1;
306 do
307 {
308 j=i*i;
309 [Link](j);
310 i++;
311 }
312 while(i<=10);
313 }
314 }
315 //(b) 1, 2, 4, 7, 11 ………………………
316 //Program to display the first ten numbers
317 public class display_do_while1
318 {
319 public static void main(String args[])
320 {
321 int i,j=1;i=1;
322 do
323 {
324 [Link](j+" ");
325 j+=i;
326 i++;
327 }
328 while(i<=10);
329 }
330 }
331 //(c) 3, 6, 9, 12 …………………………
332 //Program to display the first ten numbers
333 public class display_do_while2
334 {
335 public static void main(String args[])
336 {
337 int i;i=3;
338 do
339 {
340 [Link](i);
341 i+=3;
342 }
343 while(i<=30);
344 }
345 }
346 //(d) 4, 8, 16 ,32 ……………………………
347 //Program to display the first ten numbers
348 public class display_do_while3
349 {
350 public static void main(String args[])
351 {
352 int i,j=4;i=1;
353 do
354 {
355 [Link](j);
356 j*=2;
357 i++;
358 }
359 while(i<=10);
360 }
361 }
362 //(e) 1.5, 3.0, 4.5, 6.0 ……………………………
363 //Program to display the first ten numbers
364 public class display_do_while4
365 {
366 public static void main(String args[])
367 {
368 double i,j=1;i=1;
369 do
370 {
371 [Link](j);
372 j=1.5*i;
373 i++;
374 }
375 while(i<=10);
376 }
377 }
378 //(f) 0, 7, 26 ………………………………
379 //Program to display the first ten numbers
380 public class display_do_while5
381 {
382 public static void main(String args[])
383 {
384 int i;i=1;
385 do
386 {
387 [Link](i*i*i-1);
388 i++;
389 }
390 while(i<=10);
391 }
392 }
393 //(g) 1, 9, 25, 49 ………………………………
394 //Program to display the first ten numbers
395 public class display_do_while6
396 {
397 public static void main(String args[])
398 {
399 int i;i=1;
400 do
401 {
402 [Link](i*i);
403 i+=2;
404 }
405 while(i<=20);
406 }
407 }
408 //(h) 4, 16, 36, 64 ……………………………
409 //Program to display the first ten numbers
410 public class display_do_while7
411 {
412 public static void main(String args[])
413 {
414 int i;i=2;
415 do
416 {
417 [Link](i*i);
418 i+=2;
419 }
420 while(i<=20);
421 }
422 }
423 //(i) 0, 3, 8, 15 …………………………………..
424 //Program to display the first ten numbers
425 public class display_do_while8
426 {
427 public static void main(String args[])
428 {
429 int i;i=1;
430 do
431 {
432 [Link](i*i-1);
433 i++;
434 }
435 while(i<=10);
436 }
437 }
438 //(j) 24, 99, 224, 399 ………………………………….
439 //Program to display the first ten numbers
440 public class display_do_while9
441 {
442 public static void main(String args[])
443 {
444 int i,j=1;i=1;
445 do
446 {
447 [Link](j*j-1);
448 j=i*5;
449 i++;
450 }
451 while(i<=10);
452 }
453 }
454 //(k) 2, 5, 10, 17 ……………………………………..
455 //Program to display the first ten numbers
456 public class display_do_while10
457 {
458 public static void main(String args[])
459 {
460 int i;i=1;
461 do
462 {
463 [Link](i*i+1);
464 i++;
465 }
466 while(i<=10);
467 }
468 }
469 8. Write a program in java to find and display the sum of
470 the following series
471 (a) 1+4+9+…………………………………………..+400
472 //Program to find the sum of given series.
473 public class sum1
474 {
475 public static void main(String args[])
476 {
477 int i,s;s=0;
478 for(i=1;i<=20;i++)
479 s=s+i*i;
480 [Link](s);
481 }
482 }
483 (b) 1+1/2+1/3+…………………………………………+1/20
484 //Program to find the sum of given series.
485 public class sum2
486 {
487 public static void main(String args[])
488 {
489 double i,s;s=0;
490 for(i=1;i<=20;i++)
491 {
492 s=s+(1/i);
493 }
494 [Link](s);
495 }
496 }
497 (c) 1+1/3+1/5+………………………………….+1/19
498 //Program to find the sum of the given series
499 public class sum3
500 {
501 public static void main(String args[])
502 {
503 double i,s;s=0;
504 for(i=1;i<=20;i+=2)
505 {
506 s=s+(1/i);
507 }
508 [Link](s);
509 }
510 }
511 (d) 1/2+2/3+3/4+………………………………+19/20
512 // Program to find the sum of the given series
513 public class sum4
514 {
515 public static void main(String args[])
516 {
517 double i,s;s=0;
518 for(i=1;i<=20;i++)
519 s=s+(i/i+1);
520 [Link](s);
521 }
522 }
523 //(e) 2-4+6-8+………………………………….-20
524 // Program to find the sum of the given series
525 public class series4
526 {
527 public static void main(String args[])
528 {
529 int i,s;s=0;
530 for(i=1;i<=20;i++)
531 {
532 if((i%2==0)&&(i%4!=0))
533 s=s+i;
534 if((i%2==0)&&(i%4==0))
535 s=s-i;
536 [Link](s);
537 }
538 }
539 }
540 //(e) 2-4+6-8+………………………………….-20
541 // Program to find the sum of the given series
542 public class program//second method
543 {
544 public static void main(String args[])
545 {
546 int i,s,a;s=0;i=1;a=2;
547 while(i<=20)
548 {
549 if(i%2==0)
550 {
551 s=s-a;
552 }
553 else
554 {
555 s=s+a;
556 }
557 a=a+2;
558 [Link](s);
559 i++;
560 }
561 }
562 }
563 (f) (1*2)+(2*3)+………………………………+(19*20)
564 // Program to find the sum of the given series
565 public class sum9
566 {
567 public static void main(String args[])
568 {
569 double i,s;s=0;
570 for(i=1;i<=20;i++)
571 s=s+(i*i+1);
572 [Link](s);
573 }
574 }
575 //(a) 1+4+9+…………………………………………..+400
576 //Program to find the sum of given CopyOfseries.
577 public class series_while
578 {
579 public static void main(String args[])
580 {
581 int i,s;s=0;i=1;
582 while(i<=20)
583 {
584 s=s+(i*i);
585 i++;
586 [Link](s);
587 }
588 }
589 }
590 //(b) 1+1/2+1/3+…………………………………………+1/20
591 //Program to find the sum of given series.
592 public class series_while1
593 {
594 public static void main(String args[])
595 {
596 double i,s;s=0;i=1;
597 while(i<=20)
598 {
599 s=s+(1/i);
600 i++;
601 [Link](s);
602 }
603 }
604 }
605 //(c) 1+1/3+1/5+………………………………….+1/19
606 //Program to find the sum of the given series
607 public class series_while2
608 {
609 public static void main(String args[])
610 {
611 double i,s;s=0;i=1;
612 while(i<=20)
613 {
614 s=s+(1/i);
615 i+=2;
616 [Link](s);
617 }
618 }
619 }
620 //(d) 1/2+2/3+3/4+………………………………+19/20
621 // Program to find the sum of the given series
622 public class series_while3
623 {
624 public static void main(String args[])
625 {
626 double i,s;s=0;i=1;
627 while(i<=20)
628 {
629 s=s+(i/i+1);
630 i++;
631 [Link](s);
632 }
633 }
634 }
635 //(e) 2-4+6-8+………………………………….-20
636 // Program to find the sum of the given series
637 public class series_while4
638 {
639 public static void main(String args[])
640 {
641 int i,s;s=0;i=1;
642 while(i<=20)
643 {
644 if((i%2==0)&&(i%4!=0))
645 s=s+i;
646 if((i%2==0)&&(i%4==0))
647 s=s-i;
648 i++;
649
650 [Link](s);
651 }
652 }
653 }
654 //(f) (1*2)+(2*3)+………………………………+(19*20)
655 // Program to find the sum of the given series
656 public class series_while5
657 {
658 public static void main(String args[])
659 {
660 double i,s;s=0;i=1;
661 while(i<=20)
662 {
663 s=s+(i*i+1);
664 i++;
665 [Link](s);
666 }
667 }
668 }
669 //(a) 1+4+9+…………………………………………..+400
670 //Program to find the sum of given CopyOfseries.
671 public class series_do_while
672 {
673 public static void main(String args[])
674 {
675 int i,s;s=0;i=1;
676 do
677 {
678 s=s+(i*i);
679 i++;
680 [Link](s);
681 }
682 while(i<=20);
683 }
684 }
685 //(b) 1+1/2+1/3+…………………………………………+1/20
686 //Program to find the sum of given series.
687 public class series_do_while1
688 {
689 public static void main(String args[])
690 {
691 double i,s;s=0;i=1;
692 do
693 {
694 s=s+(1/i);
695 i++;
696 [Link](s);
697 }
698 while(i<=20);
699 }
700 }
701 //(c) 1+1/3+1/5+………………………………….+1/19
702 //Program to find the sum of the given series
703 public class series_do_while2
704 {
705 public static void main(String args[])
706 {
707 double i,s;s=0;i=1;
708 do
709 {
710 s=s+(1/i);
711 i+=2;
712 [Link](s);
713 }
714 while(i<=20);
715 }
716 }
717 //(d) 1/2+2/3+3/4+………………………………+19/20
718 // Program to find the sum of the given series
719 public class series_do_while3
720 {
721 public static void main(String args[])
722 {
723 double i,s;s=0;i=1;
724 do
725 {
726 s=s+(i/i+1);
727 i++;
728 [Link](s);
729 }
730 while(i<=20);
731 }
732 }
733 //(e) 2-4+6-8+………………………………….-20
734 // Program to find the sum of the given series
735 public class series_do_while4
736 {
737 public static void main(String args[])
738 {
739 int i,s;s=0;i=1;
740 do
741 {
742 if((i%2==0)&&(i%4!=0))
743 s=s+i;
744 if((i%2==0)&&(i%4==0))
745 s=s-i;
746 i++;
747 }
748 [Link](s);
749 while(i<=20);
750 }
751 }
752 //(f) (1*2)+(2*3)+………………………………+(19*20)
753 // Program to find the sum of the given series
754 public class series_do_while5
755 {
756 public static void main(String args[])
757 {
758 double i,s;s=0;i=1;
759 do
760 {
761 s=s+(i*i+1);
762 i++;
763 [Link](s);
764 }
765 while(i<=20);
766 }
767 }
768 12. Write a program in Java to find and display the sum of
769 the following series.
770 //(a) S=
771 a2+a2/2+a3/3+………………………………………………….+a2/10
772 //Program to find the sum of the given series
773 public class sum
774 {
775 public static void main(String args[])
776 {
777 int a,i;a=2;
778 double s;s=0;
779 for(i=1;i<=10;i++)
780 {
781 s=s+(a*a)/i;
782 [Link]("The sum of the given series="+s);
783 }
784 }
785 }
786 //(b)S=
787 a+a2/2+a3/3+…………………………………………………+a10/10
788 //Program to find the sum of the given series
789 public class sum1
790 {
791 public static void main(String args[])
792 {
793 int a,i;a=2;
794 double s;s=0;
795 for(i=1;i<=10;i++)
796 {
797 s=s+([Link](a,i)/i);
798 [Link]("The sum of the given series="+s);
799 }
800 }
801 }
802 // (c) S=
803 (a*2)+(a*3)+……………………………………………………+(a*20)
804 //Program to find the sum of the given series
805 public class sum2
806 {
807 public static void main(String args[])
808 {
809 int a,i;a=2;
810 double s;s=0;
811 for(i=1;i<=20;i++)
812 {
813 s=s+(a*i);
814 [Link]("The sum of the given series="+s);
815 }
816 }
817 }
818 //(d)
819 S=a+a2+a3+………………………………………………………………+a
820 n
821 //Program to find the sum of the given series
822 public class sum3
823 {
824 public static void main(String args[])
825 {
826 int a,i,n;a=2;n=20;
827 double s;s=0;
828 for(i=1;i<=n;i++)
829 {
830 s=s+[Link](a,i);
831 [Link]("The sum of the given series="+s);
832 }
833 }
834 }
835 //(e) S=1+22/a+33/a2+…………………………………………….to n
836 terms.
837 //Program to find the sum of the given series
838 public class sum4
839 {
840 public static void main(String args[])
841 {
842 int a,i,n;a=2;n=10;
843 double s;s=0;
844 for(i=1;i<=n;i++)
845 {
846 s=s+([Link](i,i)/[Link](a,i-1));
847 [Link]("The sum of the given series="+s);
848 }
849 }
850 }
851 //(f) S=12/a+33/a2+55/a3……………………………………………to n
852 terms.
853 //Program to find the sum of the given series
854 public class sum5
855 {
856 public static void main(String args[])
857 {
858 int a,i,n;a=2;n=10;
859 double s;s=0;
860 for(i=0;i<=n;i++)
861 {
862 s=s+([Link]((2*i+1),2)/[Link](a,i+1));
863 [Link]("The sum of the given series="+s);
864 }
865 }
866 }
867 //(g) S=1/a+1/a2+1/a3………………………………………+1/an
868 //Program to find the sum of the given series
869 public class sum6
870 {
871 public static void main(String args[])
872 {
873 int a,i,n;a=2;n=10;
874 double s;s=0;
875 for(i=1;i<=n;i++)
876 {
877 s=s+1/[Link](a,i);
878 [Link]("The sum of the given series="+s);
879 }
880 }
881 }
882 //(h) S=x/2+x/5+x/8+x/11+…………………………………+x/20
883 //Program to find the sum of the given series
884 public class sum7
885 {
886 public static void main(String args[])
887 {
888 int i,x;x=2;
889 double s;s=0;
890 for(i=1;i<=20;i+=3)
891 {
892 s=s+(x/i);
893 [Link]("The sum of the given series="+s);
894 }
895 }
896 }
897 //(a) S=
898 a2+a2/2+a3/3+………………………………………………….+a2/10
899 //Program to find the sum of the given series
900 public class sum_while
901 {
902 public static void main(String args[])
903 {
904 int a,i;a=2;
905 double s;s=0;i=1;
906 while(i<=10)
907 {
908 s=s+(a*a)/i;
909 i++;
910 [Link]("The sum of the given series="+s);
911 }
912 }
913 }
914 //(b)S=
915 a+a2/2+a3/3+…………………………………………………+a10/10
916 //Program to find the sum of the given series
917 public class sum_while1
918 {
919 public static void main(String args[])
920 {
921 int a,i;a=2;
922 double s;s=0;i=1;
923 while(i<=10)
924 {
925 s=s+([Link](a,i)/i);
926 i++;
927 [Link]("The sum of the given series="+s);
928 }
929 }
930 }
931 // (c) S=
932 (a*2)+(a*3)+……………………………………………………+(a*20)
933 //Program to find the sum of the given series
934 public class sum_while2
935 {
936 public static void main(String args[])
937 {
938 int a,i;a=2;
939 double s;s=0;i=1;
940 while(i<=20)
941 {
942 s=s+(a*i);
943 i++;
944 [Link]("The sum of the given series="+s);
945 }
946 }
947 }
948 //(d)
949 S=a+a2+a3+………………………………………………………………+a
950 n
951 //Program to find the sum of the given series
952 public class sum_while3
953 {
954 public static void main(String args[])
955 {
956 int a,i,n;a=2;n=20;
957 double s;s=0;i=1;
958 while(i<=n)
959 {
960 s=s+[Link](a,i);
961 i++;
962 [Link]("The sum of the given series="+s);
963 }
964 }
965 }
966 //(e) S=1+22/a+33/a2+…………………………………………….to n
967 terms.
968 //Program to find the sum of the given series
969 public class sum_while4
970 {
971 public static void main(String args[])
972 {
973 int a,i,n;a=2;n=10;
974 double s;s=0;i=1;
975 while(i<=n)
976 {
977 s=s+([Link](i,i)/[Link](a,i-1));
978 i++;
979 [Link]("The sum of the given series="+s);
980 }
981 }
982 }
983 //(f) S=12/a+33/a2+55/a3……………………………………………to n
984 terms.
985 //Program to find the sum of the given series
986 public class sum_while5
987 {
988 public static void main(String args[])
989 {
990 int a,i,n;a=2;n=10;
991 double s;s=0;i=0;
992 while(i<=n)
993 {
994 s=s+([Link]((2*i+1),2)/[Link](a,i+1));
995 i++;
996 [Link]("The sum of the given series="+s);
997 }
998 }
999 }
1000 //(g) S=1/a+1/a2+1/a3………………………………………+1/an
1001 //Program to find the sum of the given series
1002 public class sum_while6
1003 {
1004 public static void main(String args[])
1005 {
1006 int a,i,n;a=2;n=10;
1007 double s;s=0;i=1;
1008 while(i<=n)
1009 {
1010 s=s+1/[Link](a,i);
1011 i++;
1012 [Link]("The sum of the given series="+s);
1013 }
1014 }
1015 }
1016 //(h) S=x/2+x/5+x/8+x/11+…………………………………+x/20
1017 //Program to find the sum of the given series
1018 public class sum_while7
1019 {
1020 public static void main(String args[])
1021 {
1022 int i,x;x=2;
1023 double s;s=0;i=1;
1024 while(i<=20)
1025 {
1026 s=s+(x/i);
1027 i+=3;
1028 [Link]("The sum of the given series="+s);
1029 }
1030 }
1031 }
1032 //(a) S=
1033 a2+a2/2+a3/3+………………………………………………….+a2/10
1034 //Program to find the of the given series
1035 public class sum_do_while
1036 {
1037 public static void main(String args[])
1038 {
1039 int a,i;a=2;
1040 double s;s=0;i=1;
1041 do
1042 {
1043 s=s+(a*a)/i;
1044 i++;
1045 [Link]("The sum of the given series="+s);
1046 }
1047 while(i<=10);
1048 }
1049 }
1050 //(b)S=
1051 a+a2/2+a3/3+…………………………………………………+a10/10
1052 //Program to find the sum of the given series
1053 public class sum_do_while1
1054 {
1055 public static void main(String args[])
1056 {
1057 int a,i;a=2;
1058 double s;s=0;i=1;
1059 do
1060 {
1061 s=s+([Link](a,i)/i);
1062 i++;
1063 [Link]("The sum of the given series="+s);
1064 }
1065 while(i<=10);
1066 }
1067 }
1068 // (c) S=
1069 (a*2)+(a*3)+……………………………………………………+(a*20)
1070 //Program to find the sum of the given series
1071 public class sum_do_while2
1072 {
1073 public static void main(String args[])
1074 {
1075 int a,i;a=2;
1076 double s;s=0;i=1;
1077 do
1078 {
1079 s=s+(a*i);
1080 i++;
1081 [Link]("The sum of the given series="+s);
1082 }
1083 while(i<=20);
1084 }
1085 }
1086 //(d)
1087 S=a+a2+a3+………………………………………………………………+a
1088 n
1089 //Program to find the sum of the given series
1090 public class sum_do_while3
1091 {
1092 public static void main(String args[])
1093 {
1094 int a,i,n;a=2;n=20;
1095 double s;s=0;i=1;
1096 do
1097 {
1098 s=s+[Link](a,i);
1099 i++;
1100 [Link]("The sum of the given series="+s);
1101 }
1102 while(i<=n);
1103 }
1104 }
1105 //(e) S=1+22/a+33/a2+…………………………………………….to n
1106 terms.
1107 //Program to find the sum of the given series
1108 public class sum_do_while4
1109 {
1110 public static void main(String args[])
1111 {
1112 int a,i,n;a=2;n=10;
1113 double s;s=0;i=1;
1114 do
1115 {
1116 s=s+([Link](i,i)/[Link](a,i-1));
1117 i++;
1118 [Link]("The sum of the given series="+s);
1119 }
1120 while(i<=n);
1121 }
1122 }
1123 //(f) S=12/a+33/a2+55/a3……………………………………………to n
1124 terms.
1125 //Program to find the sum of the given series
1126 public class sum_do_while5
1127 {
1128 public static void main(String args[])
1129 {
1130 int a,i,n;a=2;n=10;
1131 double s;s=0;i=0;
1132 do
1133 {
1134 s=s+([Link]((2*i+1),2)/[Link](a,i+1));
1135 i++;
1136 [Link]("The sum of the given series="+s);
1137 }
1138 while(i<=n);
1139 }
1140 }
1141 //(g) S=1/a+1/a2+1/a3………………………………………+1/an
1142 //Program to find the sum of the given series
1143 public class sum_do_while6
1144 {
1145 public static void main(String args[])
1146 {
1147 int a,i,n;a=2;n=10;
1148 double s;s=0;i=1;
1149 do
1150 {
1151 s=s+1/[Link](a,i);
1152 i++;
1153 [Link]("The sum of the given series="+s);
1154 }
1155 while(i<=n);
1156 }
1157 }
1158 //(h) S=x/2+x/5+x/8+x/11+…………………………………+x/20
1159 //Program to find the sum of the given series
1160 public class sum_do_while7
1161 {
1162 public static void main(String args[])
1163 {
1164 int i,x;x=2;
1165 double s;s=0;i=1;
1166 do
1167 {
1168 s=s+(x/i);
1169 i+=3;
1170 [Link]("The sum of the given series="+s);
1171 }
1172 while(i<=20);
1173 }
1174 }
1175
1176 //(f) (1*2)+(2*3)+………………………………+(19*20)
1177 // Program to find the sum of the given series
1178 public class series_do_while5
1179 {
1180 public static void main(String args[])
1181 {
1182 double i,s;s=0;i=1;
1183 do
1184 {
1185 s=s+(i*i+1);
1186 i++;
1187 [Link](s);
1188 }
1189 while(i<=20);
1190 }
1191 }
1192 //(e) 2-4+6-8+………………………………….-20
1193 // Program to find the sum of the given series
1194 public class series_do_while4
1195 {
1196 public static void main(String args[])
1197 {
1198 int i,s;s=0;i=1;
1199 do
1200 {
1201 if(i%2==0)
1202 s=s-(i*2);
1203 else
1204 s=s+(i*2);
1205 i++;
1206 [Link](s);
1207 }
1208 while(i<=20);
1209 }
1210 }
1211 //(f) (1*2)+(2*3)+………………………………+(19*20)
1212 // Program to find the sum of the given series
1213 public class series_while5
1214 {
1215 public static void main(String args[])
1216 {
1217 double i,s;s=0;i=1;
1218 while(i<=20)
1219 {
1220 s=s+(i*i+1);
1221 i++;
1222 [Link](s);
1223 }
1224 }
1225 }
1226 //(e) 2-4+6-8+………………………………….-20
1227 // Program to find the sum of the given series
1228 public class series_while4
1229 {
1230 public static void main(String args[])
1231 {
1232 int i,s;s=0;i=1;
1233 while(i<=20)
1234 {
1235 if(i%2==0)
1236 s=s-(i*2);
1237 else
1238 s=s+(i*2);
1239 i++;
1240 [Link](s);
1241 }
1242 }
1243 }
1244 //(d) 1/2+2/3+3/4+………………………………+19/20
1245 // Program to find the sum of the given series
1246 public class series_do_while3
1247 {
1248 public static void main(String args[])
1249 {
1250 double i,s;s=0;i=1;
1251 do
1252 {
1253 s=s+(i/i+1);
1254 i++;
1255 [Link](s);
1256 }
1257 while(i<=20);
1258 }
1259 }
1260 //(d) 1/2+2/3+3/4+………………………………+19/20
1261 // Program to find the sum of the given series
1262 public class series_while3
1263 {
1264 public static void main(String args[])
1265 {
1266 double i,s;s=0;i=1;
1267 while(i<=20)
1268 {
1269 s=s+(i/i+1);
1270 i++;
1271 [Link](s);
1272 }
1273 }
1274 }
1275 //(c) 1+1/3+1/5+………………………………….+1/19
1276 //Program to find the sum of the given series
1277 public class series_do_while2
1278 {
1279 public static void main(String args[])
1280 {
1281 double i,s;s=0;i=1;
1282 do
1283 {
1284 s=s+(1/i);
1285 i+=2;
1286 [Link](s);
1287 }
1288 while(i<=20);
1289 }
1290 }
1291 //(c) 1+1/3+1/5+………………………………….+1/19
1292 //Program to find the sum of the given series
1293 public class series_while2
1294 {
1295 public static void main(String args[])
1296 {
1297 double i,s;s=0;i=1;
1298 while(i<=20)
1299 {
1300 s=s+(1/i);
1301 i+=2;
1302 [Link](s);
1303 }
1304 }
1305 }
1306 //(b) 1+1/2+1/3+…………………………………………+1/20
1307 //Program to find the sum of given series.
1308 public class series_do_while1
1309 {
1310 public static void main(String args[])
1311 {
1312 double i,s;s=0;i=1;
1313 do
1314 {
1315 s=s+(1/i);
1316 i++;
1317 [Link](s);
1318 }
1319 while(i<=20);
1320 }
1321 }
1322 //(b) 1+1/2+1/3+…………………………………………+1/20
1323 //Program to find the sum of given series.
1324 public class series_while1
1325 {
1326 public static void main(String args[])
1327 {
1328 double i,s;s=0;i=1;
1329 while(i<=20)
1330 {
1331 s=s+(1/i);
1332 i++;
1333 [Link](s);
1334 }
1335 }
1336 }
1337 //(a) 1+4+9+…………………………………………..+400
1338 //Program to find the sum of given CopyOfseries.
1339 public class series_do_while
1340 {
1341 public static void main(String args[])
1342 {
1343 int i,s;s=0;i=1;
1344 do
1345 {
1346 s=s+(i*i);
1347 i++;
1348 [Link](s);
1349 }
1350 while(i<=20);
1351 }
1352 }
1353 //(a) 1+4+9+…………………………………………..+400
1354 //Program to find the sum of given series.
1355 public class series_while
1356 {
1357 public static void main(String args[])
1358 {
1359 int i,s;s=0;i=1;
1360 while(i<=20)
1361 {
1362 s=s+(i*i);
1363 i++;
1364 [Link](s);
1365 }
1366 }
1367 }
1368 //(e) 2-4+6-8+………………………………….-20
1369 // Program to find the sum of the given series
1370 public class series4
1371 {
1372 public static void main(String args[])
1373 {
1374 int i,s;s=0;
1375 for(i=1;i<=20;i++)
1376 {
1377 if(i%2==0)
1378 s=s-(i*2);
1379 else
1380 s=s+(i*2);
1381 [Link](s);
1382 }
1383 }
1384 }
1385 //(f) (1*2)+(2*3)+………………………………+(19*20)
1386 // Program to find the sum of the given series
1387 public class series5
1388 {
1389 public static void main(String args[])
1390 {
1391 double i,s;s=0;
1392 for(i=1;i<=20;i++)
1393 {
1394 s=s+(i*i+1);
1395 [Link](s);
1396 }
1397 }
1398 }
1399 //(d) 1/2+2/3+3/4+………………………………+19/20
1400 // Program to find the sum of the given series
1401 public class series3
1402 {
1403 public static void main(String args[])
1404 {
1405 double i,s;s=0;
1406 for(i=1;i<=20;i++)
1407 {
1408 s=s+(i/i+1);
1409 [Link](s);
1410 }
1411 }
1412 }
1413 //(c) 1+1/3+1/5+………………………………….+1/19
1414 //Program to find the sum of the given series
1415 public class series2
1416 {
1417 public static void main(String args[])
1418 {
1419 double i,s;s=0;
1420 for(i=1;i<=20;i+=2)
1421 {
1422 s=s+(1/i);
1423 [Link](s);
1424 }
1425 }
1426 }
1427 //(b) 1+1/2+1/3+…………………………………………+1/20
1428 //Program to find the sum of given series.
1429 public class series1
1430 {
1431 public static void main(String args[])
1432 {
1433 double i,s;s=0;
1434 for(i=1;i<=20;i++)
1435 {
1436 s=s+(1/i);
1437 [Link](s);
1438 }
1439 }
1440 }
1441 //(a) 1+4+9+…………………………………………..+400
1442 //Program to find the sum of given series.
1443 public class series
1444 {
1445 public static void main(String args[])
1446 {
1447 int i,s;s=0;
1448 for(i=1;i<=20;i++)
1449 {
1450 s=s+(i*i);
1451 [Link](s);
1452 }
1453 }
1454 }
1455 //(k) 2, 5, 10, 17 ……………………………………..
1456 //Program to display the first ten numbers
1457 public class display_do_while10
1458 {
1459 public static void main(String args[])
1460 {
1461 int i;i=1;
1462 do
1463 {
1464 [Link](i*i+1);
1465 i++;
1466 }
1467 while(i<=10);
1468 }
1469 }
1470 //(k) 2, 5, 10, 17 ……………………………………..
1471 //Program to display the first ten numbers
1472 public class display_while10
1473 {
1474 public static void main(String args[])
1475 {
1476 int i;i=1;
1477 while(i<=10)
1478 {
1479 [Link](i*i+1);
1480 i++;
1481 }
1482 }
1483 }
1484 //(j) 24, 99, 224, 399 ………………………………….
1485 //Program to display the first ten numbers
1486 public class display_do_while9
1487 {
1488 public static void main(String args[])
1489 {
1490 int i,j=1;i=1;
1491 do
1492 {
1493 [Link](j*j-1);
1494 j=i*5;
1495 i++;
1496 }
1497 while(i<=10);
1498 }
1499 }
1500
1501
1502
1503
1504
1505
1506 //(j) 24, 99, 224, 399 ………………………………….
1507 //Program to display the first ten numbers
1508 public class display_while9
1509 {
1510 public static void main(String args[])
1511 {
1512 int i,j=1;i=1;
1513 while(i<=10)
1514 {
1515 [Link](j*j-1);
1516 j=i*5;
1517 i++;
1518 }
1519 }
1520 }
1521
1522
1523
1524
1525
1526 //(i) 0, 3, 8, 15 …………………………………..
1527 //Program to display the first ten numbers
1528 public class display_do_while8
1529 {
1530 public static void main(String args[])
1531 {
1532 int i;i=1;
1533 do
1534 {
1535 [Link](i*i-1);
1536 i++;
1537 }
1538 while(i<=10);
1539 }
1540 }
1541
1542
1543
1544
1545
1546
1547
1548 //(i) 0, 3, 8, 15 …………………………………..
1549 //Program to display the first ten numbers
1550 public class display_while8
1551 {
1552 public static void main(String args[])
1553 {
1554 int i;i=1;
1555 while(i<=10)
1556 {
1557 [Link](i*i-1);
1558 i++;
1559 }
1560 }
1561 }
1562
1563
1564
1565
1566
1567
1568 //(h) 4, 16, 36, 64 ……………………………
1569 //Program to display the first ten numbers
1570 public class display_do_while7
1571 {
1572 public static void main(String args[])
1573 {
1574 int i;i=2;
1575 do
1576 {
1577 [Link](i*i);
1578 i+=2;
1579 }
1580 while(i<=20);
1581 }
1582 }
1583
1584
1585
1586
1587 //(h) 4, 16, 36, 64 ……………………………
1588 //Program to display the first ten numbers
1589 public class display_while7
1590 {
1591 public static void main(String args[])
1592 {
1593 int i;i=2;
1594 while(i<=20)
1595 {
1596 [Link](i*i);
1597 i+=2;
1598 }
1599 }
1600 }
1601
1602
1603
1604
1605
1606
1607 //(g) 1, 9, 25, 49 ………………………………
1608 //Program to display the first ten numbers
1609 public class display_do_while6
1610 {
1611 public static void main(String args[])
1612 {
1613 int i;i=1;
1614 do
1615 {
1616 [Link](i*i);
1617 i+=2;
1618 }
1619 while(i<=20);
1620 }
1621 }
1622
1623
1624
1625
1626 //(g) 1, 9, 25, 49 ………………………………
1627 //Program to display the first ten numbers
1628 public class display_while6
1629 {
1630 public static void main(String args[])
1631 {
1632 int i;i=1;
1633 while(i<=20)
1634 {
1635 [Link](i*i);
1636 i+=2;
1637 }
1638 }
1639 }
1640
1641
1642
1643
1644
1645 //(f) 0, 7, 26 ………………………………
1646 //Program to display the first ten numbers
1647 public class display_do_while5
1648 {
1649 public static void main(String args[])
1650 {
1651 int i;i=1;
1652 do
1653 {
1654 [Link](i*i*i-1);
1655 i++;
1656 }
1657 while(i<=10);
1658 }
1659 }
1660
1661
1662
1663
1664
1665
1666 //(f) 0, 7, 26 ………………………………
1667 //Program to display the first ten numbers
1668 public class display_while5
1669 {
1670 public static void main(String args[])
1671 {
1672 int i;i=1;
1673 while(i<=10)
1674 {
1675 [Link](i*i*i-1);
1676 i++;
1677 }
1678 }
1679 }
1680
1681
1682
1683
1684 //(e) 1.5, 3.0, 4.5, 6.0 ……………………………
1685 //Program to display the first ten numbers
1686 public class display_do_while4
1687 {
1688 public static void main(String args[])
1689 {
1690 double i,j=1;i=1;
1691 do
1692 {
1693 [Link](j);
1694 j=1.5*i;
1695 i++;
1696 }
1697 while(i<=10);
1698 }
1699 }
1700
1701
1702
1703
1704
1705
1706 //(e) 1.5, 3.0, 4.5, 6.0 ……………………………
1707 //Program to display the first ten numbers
1708 public class display_while4
1709 {
1710 public static void main(String args[])
1711 {
1712 double i,j=1;i=1;
1713 while(i<=10)
1714 {
1715 [Link](j);
1716 j=1.5*i;
1717 i++;
1718 }
1719 }
1720 }
1721
1722
1723
1724
1725
1726 //(d) 4, 8, 16 ,32 ……………………………
1727 //Program to display the first ten numbers
1728 public class display_do_while3
1729 {
1730 public static void main(String args[])
1731 {
1732 int i,j=4;i=1;
1733 do
1734 {
1735 [Link](j);
1736 j*=2;
1737 i++;
1738 }
1739 while(i<=10);
1740 }
1741 }
1742
1743
1744
1745
1746
1747 //(d) 4, 8, 16 ,32 ……………………………
1748 //Program to display the first ten numbers
1749 public class display_while3
1750 {
1751 public static void main(String args[])
1752 {
1753 int i,j=4;i=1;
1754 while(i<=10)
1755 {
1756 [Link](j);
1757 j*=2;
1758 i++;
1759 }
1760 }
1761 }
1762
1763
1764
1765
1766
1767 //(c) 3, 6, 9, 12 …………………………
1768 //Program to display the first ten numbers
1769 public class display_do_while2
1770 {
1771 public static void main(String args[])
1772 {
1773 int i;i=3;
1774 do
1775 {
1776 [Link](i);
1777 i+=3;
1778 }
1779 while(i<=30);
1780 }
1781 }
1782
1783
1784
1785
1786 //(c) 3, 6, 9, 12 …………………………
1787 //Program to display the first ten numbers
1788 public class display_while2
1789 {
1790 public static void main(String args[])
1791 {
1792 int i;i=3;
1793 while(i<=30)
1794 {
1795 [Link](i);
1796 i+=3;
1797 }
1798 }
1799 }
1800
1801
1802
1803
1804
1805
1806 //(b) 1, 2, 4, 7, 11 ………………………
1807 //Program to display the first ten numbers
1808 public class display_do_while1
1809 {
1810 public static void main(String args[])
1811 {
1812 int i,j=1;i=1;
1813 do
1814 {
1815
1816 [Link](j+" ");
1817 j+=i;
1818 i++;
1819 }
1820 while(i<=10);
1821
1822 }
1823 }
1824
1825
1826
1827
1828
1829 //(b) 1, 2, 4, 7, 11 ………………………
1830 //Program to display the first ten numbers
1831 public class display_while1
1832 {
1833 public static void main(String args[])
1834 {
1835 int i,j=1;i=1;
1836 while(i<=10)
1837 {
1838 [Link](j+" ");
1839 j+=i;
1840 i++;
1841 }
1842 }
1843 }
1844
1845
1846
1847
1848
1849
1850
1851
1852 //(a) 1, 4, 9, 16 …………………………
1853 //Program to display the first ten numbers
1854 public class display_do_while
1855 {
1856 public static void main(String args[])
1857 {
1858 int i,j;i=1;
1859 do
1860 {
1861 j=i*i;
1862
1863 [Link](j);
1864 i++;
1865 }
1866 while(i<=10);
1867
1868 }
1869 }
1870
1871
1872
1873
1874 }
1875 }
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895