**Past Questions On Introduction To Basic Programming 2011/2012**

**MATHS/STATS. & COMPUTER SCIENCE**

UNIVERSITY OF CALABAR

SECOND SEMESTER EXAMINATION 2011/2012 SESSION

CSC 1182- INTRODUCTION TO BASIC PROG. TIME:1hr.40mins

Instruction: Answer any two questions from section A and All in section B.

Section A. Theory – 40% 1hr

UNIVERSITY OF CALABAR

SECOND SEMESTER EXAMINATION 2011/2012 SESSION

CSC 1182- INTRODUCTION TO BASIC PROG. TIME:1hr.40mins

Instruction: Answer any two questions from section A and All in section B.

Section A. Theory – 40% 1hr

1. Write a BASIC program that allows you find the average score of 5 students offering 5 courses: either (i). Without using IF-THEN statement or (ii). With the use of IF-THEN statement or (ii) Using For-To-Next statement.

(b). Write a BASIC program to produce the first 100 Fibonacci numbers.

2. If a man has 6children and each child scored 5 different marks in 5 different courses, write a BASIC program that will, for each child, find the average mark and print out the result into a text file.

(b). Write a BASIC program that can produce the Greatest Common Divisor (GCD) given two integers.

3. Study the program below and answer the following questions: (i). Draw a flowchart for it

(ii). What will be the output? (iii). Rewrite the program using for next loop.

k=1

40 p=p+k^3-k^2

Print k, p, p^2

k=k+1

If k<=5 THEN 40; 75 GOTO 80 80 END

(b). Write a BASIC program that can produce the Lowest Common Multiple (LCM) given two integers.

4. A class of four students had exams in 4 different courses and performed as follows:

NAMES CSC1102 CSC1182 CSC1352 CSC1241 SAS

PETER 70 60 14 31 ?

JOHN 54 56 62 28 ?

COMFORT 89 82 86 60 ?

CHRISTY 61 90 84 72 ?

CAS ? ? ? ? ?

NAMES CSC1102 CSC1182 CSC1352 CSC1241 SAS

PETER 70 60 14 31 ?

JOHN 54 56 62 28 ?

COMFORT 89 82 86 60 ?

CHRISTY 61 90 84 72 ?

CAS ? ? ? ? ?

Write a program to (i) Read in the scores of each student in all the courses. (ii). Sum the total scores of each course and find the class average score (CAS). (iii). Sum the total score of each student and find the student’s average score (SAS).

(b). What is an array?

**Section B: Lab section (Alternative to practicals) -60% 40 mins**

Study the program below and answer the questions that follows.

1. CLS

2. OPEN”felixp.txt” FOR OUTPUT AS #1

3. INPUT N4. DIM a(N)

5. a(1)=0

6.

7. FOR i= 2 TO N STEP 1

8. a(i)=1

9. NEXT I

10.

11. FOR I = 2 TO N / 2 STEP 1

12. FOR j = 2 TO N / 2 STEP 1

13. a(i*j) = 0

14. NEXT j

15. NEXT i

16.

17. FOR I = 1 TO N STEP 1

18. IF a(i) = 1 THEN PRINT #1, I; “ is a PN “

19. PRINT

20. NEXT i

21.

22. END.

(a). What is the program’s main aim?

(b). Explain what each line of code does.

(c). If the program is run, what do you expect as the prompt?

(d). Assume you are asked to split this program into sub-routines, how many would you create. Give them arbitrary names.

(e). Prepare an execution frame for lines 11 to 15; given that N is 10.

(f). What is the loop of line 7 to 9 doing to the array a(i)

(g). To what level is the array a(i) different from that of a(i*j) found in lines 8 and 13 respectively.

(h). The array index i is set to 1 in line 8 and that of i*j is set to 0 in line 13, what are the properties of these array indexes?

(i). What is the intention of the construction of the loop of 17 to 20

(j). Having gotten a fair knowledge of the result from the execution frame, what do you think PN stands for? Hence if N is given as 10, what would be the first five series of the result?

Also Read:

**BASIC Program For Sum of Numbers Using IF Then Statement**

**Pascal Arithmetic Program Using IF THEN statement**

**Pascal Program to Create and Save Records in a Textfile**

**Pascal program To Calculate Area of a Triangle**

**Pascal Program of Matrix Multiplication**

Pascal Program to Read in Even Numbers Into An Array

**Pascal Program to Find The Average Of Only Positive Numbers Using While Do loop**

Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:

HTML Link Code:

BB (forum) link code:

## Comments

## Post a Comment

Please share your views on this topic with Grace Joseph by leaving a comment.