Thursday, August 4, 2011

Qbasic (Display Recorded Data)

Write a QBASIC program to display data from a sequential data file "info.dat" with field name Id, Name, Address, Post and salary.
OPEN "info.dat" FOR INPUT AS #1
CLS
While not EOF(1)
PRINT "Id", "Name", "Address", "Post", "Salary"
INPUT #1, ID, N$,A$,P$,S
PRINT ID, N$,A$,P$, S
CLOSE #1
END

Qbasic (Store Data)

OPEN "info.dat" FOR OUTPUT AS #1
CLS
TOP :
INPUT "Enter your Id"; ID
INPUT "Enter your Name "; Name$
INPUT "Enter your Address"; Ad$
INPUT "Enter your Post"; Po$
INPUT "Enter your Salary"; Sa
WRITE #1, ID, Name$,Ad$,Po$, Sa
INPUT "Do you want to enter next record (Y/N)"; y$
IF UCASE$(Y$)="Y" THEN GOTO TOP
CLOSE #1
END

Thursday, July 28, 2011

Qbasic (Find Area of Four Walls)

DECLARE FUNCTION AR(N, A, M)
INput "Enter the height"; h
Input "Enter the length"; l
Input "Enter the breadth"; b
Area = Ar(N, A, M)
Print "Area of fout walls"; Area
End

Function Ar(N,A, M)
Ar = 2*h*(l+b)
End Function

Qbasic (Find the Volume of a Circle)

Declare Function Vol(N,A)
CLS
INPUT "Enter a radius"; R
Input "Enter the height"; h
Volume = Vol (N,A)
Print "The Volume is"; Volume
END

Function VOL(N,A)
Const PI = 3.1416
Vol = Pi * R^2 *h
END FUNCTION

Wednesday, July 27, 2011

Qbasic (Find whether the given no. is palindrome)

Declare Function Palin(N)
Cls
Input "A No."; N
Pal = palin(N)
If pal = n then
Print "Numeric Palindrome"
Else
Print "Not Palindrome"
End If
End

Function Palin(N)
M=N
While M<>0
K = M mod 10
P = P*10+R
M = M\10
WEND
Palin = P
END FUNCTION

Qbasic (Find the Current Month)

Declare Function curmth$(n$())
CLS
DIM n$(12)
For J = 1 to 12
READ N$(J)
NEXT
M$ = Curmth$(N$())
Print "Current system month is "; M$
Data Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sept, Oct, Nov, Dec
End

Function Curmth$(N$())
D$ = Date$
N = Val (Left$(D$,2)
For M = 1 to 12
If N=K then
Z$ = N$(K)
ENDIF
NEXT
CURMTH$ = Z$
END FUNCTION