Stats: 3,186,569 members, 7,929,820 topics. Date: Saturday, 24 August 2024 at 12:28 AM |
Nairaland Forum / Nairaland / General / Education / Attention Computer Science Graduates (455 Views)
Faculty of Life Science Graduates Of AAU dress like Marlians / Chemical Engineering Vs Computer Science Which Has More Calculations??? / What Are The Career Opportunities For A Political Science Graduates? (2) (3) (4)
Attention Computer Science Graduates by walletxtra: 6:25pm On Jun 28, 2017 |
Kindly help me solve this BASIC programming questions: 10 LET K = 2 20 LET L = 9 30 LET SUM =0 40 FOR J = K TO STEP 2 50 SUM = SUM+ J^2 60 PRINT "ANSWER=", SUM 70 NEXT J 80 END A. How many times will the statement lines 50 and 60 be repeated? B. What is the best sequence of output for the program? C. What is the last output to be displayed by the program? |
Re: Attention Computer Science Graduates by AlanTuringAI: 6:49pm On Jun 28, 2017 |
walletxtra:Solutions : A. I want to believe you omitted L after the TO in line 40,right? If so, statement lines 50 and 60 will be repeated four (4) times as the loop will only iterate 4 times since the loop counting variable J will have four values: 2,4,6 and 8 B. Best sequence of output for the program is by swapping the contents of statement lines 60 and 70. That way we only have one final value of SUM to be displayed as the output of the program, instead of four values as the program currently is. C. Last output of the program is: ANSWER= 120. This is obtained this way: For values of J= 2,4,6,8 in each iteration, SUM =0 + 2^2 = 4 ----->1st iteration SUM =4 + 4^2 = 20 ----->2nd iteration SUM =20 + 6^2 = 56----->3rd iteration Lastly, SUM =56 + 8^2 = 120 ----->4th iteration Best of luck. 1 Like |
Re: Attention Computer Science Graduates by walletxtra: 9:46pm On Jun 28, 2017 |
Thanks a bunch |
Re: Attention Computer Science Graduates by AlanTuringAI: 10:49pm On Jun 28, 2017 |
walletxtra:You're welcome. |
(1) (Reply)
2 Futarians Drown In A River / Babcock University's Award Of Best Graduating Student / NECO-GCE 2017 Examination Timetable Is Out- Naijaclassic.com
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |