Qbasic

Avg of 3 no

Declare function avg(a,b,c)
Cls
Input"enter first number ";a
Input"enter second number";b
Input "enter third number";c
Print"avg of three number=";avg(a,b,c)
End

Function avg(a,b,c)
S=a+b+c
Av = S/3
Avg=Av
End function

Total vowel number

Declare sub count (N$)


Cls

Input "enter any word ";N$
Call count (N$)
End

Sub count (N$)
C=0
For I=1 to len(N$)
B$=Mid$ (N$,I,1)
C$=Ucase$(B$)


If C$="A" or C$="E"or C$="I" or C$="O"or C$="U"
Next I
Print"total no of vowel=";C$
End sub

Circle
Declare sub area(R)



Input "enter radius";R


Call area(R)

End
I

Sub area (R)
A=22/7*R^2
Print "area of circle=";A


End sub








Area of 4 wall

Declare sub area (l,b,h)
Cls
Input"enter length";l

Input"enter breadth";I

Input"enter height";h
Call area (l,b,h)

End

Sub area (l,b,h)
A=2*h*(l+b)
Print " area of 4 wall=";A
End sub

Area of triangle

Declare function area(b,h)


Input "enter breadth";b
Input"enter height";h
Print" area of triangle=";area(b,h)
End

Function area (b,h)







A=1/2*b*h
area =A
End function


Simple interest

Declare function interest(p,t,r)

Cls
Input " enter principal";p
Input"enter time";t

Input"enter rate";r

Print" simple interest=";interest(p,t,r)
End

Function interest(p,t,r)
Simple=p*t*r\100
Interest=Simple

End function








Area of box





Declare function area (l,b,h)
Cls
Input "enter length ";l
Input"enter breadth ";b
Input "enter height ";h
Print"area of box=";area (l,b,h)
End

Function area (l,b,h)





A=2*(l*b+b*h+l*h)
Area =A
End function



Circumference of circle

Declare sub circum (r)
Cls
Input"enter radius";r
Call circum(r)
End


Sub circum(r)




C=2*22/7*r
Print"circumference of circle=";C
End sub

GreatEst among three number

Declare sub great(a,b,c)
Cls
Input "enter first number";a
Input "enter second number";b
Input "enter third number"(c

Call great(a,b,c)

End

Sub great(a,b,c)
If a>b and a>c then
Print"the greatest number";a
Else if b>a and b>c then
Print "the greatest number";b
Else
Print"the greatest number";c
End sub


Divisible by 13 or not





Declare sub check(n)


Cls
Input "enter number";n
Call check(n)
End


Sub check(n)
If n mod 13=0 then
Print"the number is divisible by 13"


Else
Print"the number is not divisible by 13"
End sub


Area of 4 wall

Declare function area(l,b,h)
Cls
Input "enter length";l
Input"enter breadth";b
Input "enter height ";h

Print "area of 4 wall=";area(l,b,h
End

Function area(l,b,h)
A=2*h*(l+b)
area=A
End function


Natural no 1 to 5


Declare sub series()
Cls
Call series()

End

Sub series()
For I=1 to 5

Print I
Next I
End sub

Celsius into Fahrenheit

Declare function Fahrenheit (C)
Cls
Input " enter Celsius ";C
Print"temperature in Fahrenheit ";Fahrenheit (C)

End


Function Fahrenheit (C)
F=9*C/(5+32)
Fahrenheit =F
End function


First 10 odd no

Declare sub series()



Cls
Call series
End

Sub series
A=1
For I=1 to 10
Print a
a=a+2
Next I
End sub

Distance travelled


Declare function distance(u ,t,a)
Cls
Input"enter initial velocity ";u


Input"enter time";t
Input "enter acceleration ";a
Print"distance travelled ";distance(u,a,t)
End

Function distances(u,t,a)
S=u*t+1/2*a*t^2

Distance=S
End function

Positive or negative

Declare sub check(n)
Cls
Input"enter number";n
Call check(n)
End

Sub check (n)
If n>0 then
Print"the number is positive "
Else if n<0then
Print " the number is negative "
End sub

Reverse of string

Declare sub rev(w$)
Cls
Input"enter word";w$
Call rev(w$)

End

Sub rev(w$)
For I=len(w$) to 1 step -1
B$=mid$(w$,I,1)

S$=S$+B$
Next I
Print"reverse string is";S$
End sub

Count consonant

Declare function count(n$)
Cls
Input"enter any number";n$
Print " the consonant number=";count(n$)
End

Function count(n$)
C=0
For I=1 to len(n$)
B$=mid$(n$,I,1)
C$=ucase$(b$)
If C$="A" and C="E" and C$="I" and C$="o" and C$="U" then C=C+1
Next I
Count=C
End function


Sum of digits

Declare sub sum(n)

Cls
Input"enter any number";n
Call sum(n)
End

Sub sum(n)
S=0
While n<>0
R=n mod 10
S=S+R
N=N/10
Wend
Print "sum of digit";S
End sub

Factorial

Declare sub fact(n)
Cls
input " enter any number";n
Call fact(n)
End

Sub fact(n)
F=1
For I=1 to n
F=F*I
Next I
Print "factorial";f
End function

9'7,5,...1

 Declare sub series()
Cls
Call series
End

Sub series()
For I=9 to 1 step-1
Print I
Next I
End sub

1,1,2,3,5....10 term

Declare sub series()
Cls
Call series
End

Sub series()
A=1
B=1
For I=1to5
Print a
Print b
A=A+B
B=A+B
Next I
End sub

Volume of box

Declare function volume(l,b,h)
Cls
Input"enter length";l
Input"enter breadth";b
Input "enter height";h
Print "volume of box";volume(l,b,h)
End

Function volume (l,b,h)
V=l*b*h
Volume=V
End function

Palindrome

Declare function pal(n)
Cls
Input"enter any number ";n
P=pal((n))
If a=p then
Print"the no is palindrome "
Else
Print"the given no is not palindrome "
End if
end

Function pal((n))
S=0
While n<>0
R=n mod 10
S=S*10+R
N=N/10
Wend
Pal=S
End function

Prime or composite

Declare sub check (n)
Cls
Input"enter any number";n
Call check(n)
End

Sub check(n)
C=0
For I=1to n
If n mod I=0 then C=C+1
Next I
If C=2 then
Print"prime number"
Else
Print"composite number"
End of
End sub





















Comments

Popular posts from this blog

My experience with my jagat mandir family

Experience of picnic

The experience of police class teaching about drug abuse