ENOTES

Series and Pattern using function in QBASIC modular progamming

access_time May 06, 2021 remove_red_eye 4538

QBASIC is a modular programming taught in SEE Class 10 Computer Science. Modular Programming in QBASIC are done using Sub Module and Function Module. Here are some of the program example of series and patterns generated using function only.

Click here for full QBASIC notes.

Series and Pattern using function in QBASIC

Generate 1 2 3 4 5 …….10th term

DECLARE FUNCTION num(c) 
c=0 
FOR i = 1 TO 10 
PRINT num(c) 
NEXT i 
END
FUNCTION num(c) 
c=c+1 
num = c 
END FUNCTION
Generate 1 4 9 16  …….10th term

DECLARE FUNCTION num(i) 
FOR i = 1 TO 10 
PRINT num(i) 
NEXT i 
END
FUNCTION num(i)  
x=i^2
num = x
END FUNCTION
Generate 3 12 27 48 75 …….10th term

DECLARE FUNCTION num(i) 
FOR i = 1 TO 10 
PRINT num(i) 
NEXT i 
END
FUNCTION num(i)  
x=3*i^2
num = x
END FUNCTION
Generate 5 25 125 …….10th term

DECLARE FUNCTION num(i) 
FOR i = 1 TO 10 
PRINT num(i) 
NEXT i 
END
FUNCTION num(i)  
x=5^i
num = x
END FUNCTION
Generate 1 121 12321 1234321 123454321 …….10th term

DECLARE FUNCTION num(c) 
c=0
FOR i = 1 TO 10 
c=c*10+1
PRINT num(c) 
NEXT i 
END
FUNCTION num(c)  
x=c^2
num = x
END FUNCTION