Wednesday 25 March 2020

QBASIC Program of numeric series using FUNCTION statement.

Wap in QBASIC to display the following numeric series using FUNCTION statement.

i).1, 8, 27,......upto 10th term

Declare function n(i)
Cls
For i=1 to 10
Print n(i);
Next i
End
Function n(i)
n=i^3
End function

ii) 2 1 3 4 7 11 ...upto 11th term

Declare function s(a,b,c)
Cls
A=2
B=1
For i=1 to 11
Print s(a,b,c);
Next i
End
Function s(a,b,c)
S=A
C=A+B
A=B
B=C
END FUNCTION

iii). 50, 45, 35,....0

declare function r(a,b)
cls
a=50
b=5
While a>=0
Print r(a,b);
Wend
End
Function r(a,b)
r=a
a=a-b
b=b+5
end function

4).
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

Declare function n(i)
Cls
For i=1 to 5
For j=1 to i
Print n(i);
Next j
Print
Next i
End
Function n(i)
N=i
End function

5).
9 7 5 3 1
9 7 5 3
9 7 5
9 7
9

Declare function n(i)
Cls
A=1
zz:
For i=9 to a step -2
PRINT N(i);
Next i
A=a+2
Print
If a<=9 then goto zz
End
Function n(i)
n=i
End function

OR

DECLARE FUNCTION A(J)
CLS
FOR I=1 TO 9 STEP 2
FOR J=9 TO I STEP -2
PRINT A(J);
NEXT J
PRINT
NEXT I
END

FUNCTION A(J)
A=J
END FUNCTION


6) 1 12 123 1234 12345

DECLARE FUNCTION SERIES(A.B)
CLS
LET A=1
LET B=2
X=SERIES(A,B)
END
FUNCTION SERIES(A,B)
FOR =1 TO 5
PRINT A;
A=A*10+B
B=B+1
NEXT I
END FUNCTION

7)
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1

DECLARE FUNCTION A(I,J)
CLS
FOR I = 5 TO 1 STEP -1
FOR J= 1 TO 5
PRINT A(I,J);
NEXT J
PRINT
NEXT I
END
FUNCTION A(I,J)
A=I
END FUNCTION

MANY STUDENTS CONFUSE IN

*)
55555
4444 [HERE THERE IS NO SPACE
333 IN NO. BUT UP THERE IS
22 SPACE]
1

DECLARE FUNCTION A(N,I)
CLS
N = 11111
I = 5
WHILE N<>0
PRINT A(N,I);
N=N\10
I=I-1
WEND
END
FUNCTION A(N,I)
A=N*I
END FUNCTION

No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint