Sunday 2 December 2018

QBASIC PROGRAMING


Q-BASIC PROGRAMS

1)Write a program to enter your name and print it .

CLS
Input 'Enter you name';n$
Print 'The name is';n$
End

2)Write a program to enter your name, city, country, age and print them.

CLS
Input " Enter the name ";N$
Input " Enter the city";C$
Input " Enter the country";CO$
Input " Enter the age";A
Print " The name is ";N$
Print " The city is ";C$
Print " The country is ";CO$
Print " The age is ";A
End

3)Write a program to find the area of rectangle.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
let A = l*b
Print" the area of rectangle=" ;a
End

4)Write a program to find the area of the triangle.

Cls
Input " enter the base" ;b
Input " enter the height" ;h
let T = 1/2*b*h
Print" The area of triangle=" ;T
End

5)Write a program to find the area of the circle.
Cls
Input" Enter the radius " ;R
Let C=22/7*R^2
Print " The area of circle =" ;C
End

6)Write a program to find the circumference of the circle.

Cls
Input" Enter the radius " ;R
Let Circumference=22/7*R*2
Print " The area of circle =" ;Circumference
End

7)Write a program to find the area of the square.

Cls
Input" Enter the number" ;n
Let square= n^2
Print" The area of square=" ;Square
End

8)Write a program to find the area of the square and cube.

Cls
Input" Enter the number" ;n
Let square= n^2
Let Cube = n^3
Print" The area of square=" ;Square
Print" The area of cube=" ; Cube
End

9)Write a program to find the volume of the box.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
Input " enter the height " ;h
Let Volume= l*b*h
Print" The volume of box =" ;Volume
End

10)Write a program to convert the weight from kilogram to pounds.

CLS
Input"Enter the weight in kilogram";K
Let P=K*2.2
Print "The pound is ";P
End

11)Write a program to convert the distance from kilometer to miles.

Cls
Input"Enter the length in kilometer";K
Let M= K / 1.6
Print "The length in miles =";M
End

12)Write a program to convert the distance from miles to kilomiles.

Cls
Input " Enter the length in miles";M
Let K=M*1.6
Print" The length in kilo miles=";K
End

13)Write a program to enter the initial mileage(m1) and final mileage (m2) then calculate the distance traveled.

CLS
Input "Enter the Initial Mileage";M1
Input "Enter the Final Mileage";M2
Let D= M2-M1
Print " The distance covered=";D
End

14)Write a program to find out the simple Interest.

Cls
Input " Enter the Principal";P
Input " Enter the Rate";R
Input " Enter the Time";T
Let I = P*T*R/100
Print " The simple Interest = ";I
End

15)Write a program to find out the simple Interest and the Amount.

Cls
Input " Enter the Principal";P
Input " Enter the Rate";R
Input " Enter the Time";T
Let I = P*T*R/100
Let A= P + I
Print " The simple Interest = ";I
Print " The amount=";A
End

16)Write any number and find it's half.
Cls
Input "Enter the desired number "; N
Let H = N/2
Print "The half of the number = ";H
END

17)Write a program to find the area of four walls of a room.

Cls
Input"Enter the height ";H
Input"Enter the length "; L
Input"Enter the Breadth";B
Let A= 2 * H * (L+B)
Print " The area of four walls =";A
End

18)Write a program to find the perimeter of a rectangle.

Cls
Input " enter the length " ;l
Input " enter the breadth " ;b
Let P=2*(l+b)
Print" The perimeter of rectangle=" ;P
End

19)Write a program to enter any three numbers,sum and the average.

Cls
Input " Enter any number" ;A
Input " Enter any number" ;B
Input " Enter any number" ;C
Let Sum = A+B+C
Let Average =Sum/3
Print" The sum=" ;Sum
Print" The Average is " ;Average
End


20)Write a program to enter any two numbers their Sum,Product and the Difference.


CLS
Input " Enter any number" ;A
Input " Enter any number" ;B
Let Sum = A+B
Let Difference= A-B
Let Product = A*B
Print" the sum =" ;Sum
Print" the Difference =" ;Difference
Print" the Product =" ; Product
End


21)Write a program to find the average of three different numbers.

Cls
Input" Enter the number " ;A
Input" Enter the number " ;B
Input" Enter the number " ;C
Let Avg= (A+B+C)/3
Print" The average=" ;Avg
End

22)Write a program to input student's name,marks obtained in four different subjects,find the total and average marks.

Cls
Input" Enter the name " ;N$
Input" Enter the marks in English" ;E
Input" Enter the marks in Maths" ;M
Input" Enter the marks in Science" ;S
Input" Enter the marks in Nepali" ;N
Let S=E+M+S+N
Let A=S/4
Print " The name of the student is" ;N$
Print " The total marks is" ;S
Print " The Average marks" ;A
End

23)Write a program to find 10%,20% and 30% of the input number.

Cls
Input" Enter any number" ;N
Let T=10/100*N
Let Twe=20/100*N
Let Thi=30/100*N
Print " 10%of input number=" ;T
Print " 20%of input number=" ;Twe
Print " 30%of input number=" ;Thi
End

24)Write a program to convert the distance to kilometer to miles.

Cls
Input" Enter the kilometer" ;K
Let M=K/1.6
Print " The miles = " ;M
End

25)Write a program to find the perimeter of square.

Cls
Input "Enter the length"; L
Let P =4 * L
Print " The perimeter of square=";P
End

26)Write a program to enter the Nepalese currency and covert it to Indian Currency.

CLS
Input "Enter the Nepalese currency" ;N
Let I = N * 1.6
Print "the Indian currency=";I
End

27)Write a program to enter the Indian currency and covert it to Nepalese Currency.

CLS
Input "Enter the Indian currency" ;N
Let N = I / 1.6
Print "the Nepalese currency=";I
End

28)Write a program to enter any number and find out whether it is negative or positive.

CLS
Input "Enter the number"; N
If N>0 Then
Print " The number is positive"
Else
Print "The number is negative"
EndIf
End

29)Write a program to enter any number and find out whether it is even or odd using select case statement.

Cls
Input "Enter any number" ;N
R=N mod 2
Select case R
Case = 0
Print "The number is Even number"
Case Else
Print "The number is odd number"
End Select
End

30)Write a program to check the numbers between 1 & 3.

Cls
Input "Enter the numbers between 1-3";N
Select case N
Case 1
Print "It's number 1";
Case 2
Print "It's a number 2";
Case 3
Print "It's a number 3"
Case else
Print "It's out of range";
End select
End

31)Write a program to enter any alphabet and test alphabet is 'a' or not using the select case statement.

Cls
Input "Enter the alphabet";A$
A$=UCase$ (A$)
Select Case A$
Case 'A'
Print "It's alphabet A"
Case Else
Print "It's not alphabet A"
End Select
End

32)Write a program to enter any alphabet and find out whether the number is vowel or alphabet.

Cls
Input "Enter Letters/Alphabet";A$
A$ = UCase $ (A$)
Select case A$
Case "A", "E", "I", "O", "U"
Print "Its' a vowel"
Case Else
Print " It's not a vowel"
End Select
End

33)Generate the following numbers using For….Next…..Loop.
1,2,3,4,…,50

CLS
For I = 1 to 50 Step 1
Print I
Next I
End

34)Generate the following numbers using For….Next…..Loop.
1,3,5,7,9,....99
Cls
For I = 1 to 99 Step 2
Print I
Next I
End

35)Generate the following numbers using For….Next…..Loop.
2,4,6,8,10,…50

Cls
For I = 2 to 50 Step 2
Print I
Next I
End

36)Generate the following numbers using For….Next…..Loop.
1,3,5,7,…99

Cls
For I = 1 to 99 Step 2
Print I
Next I
End


37)Generate the following numbers using For….Next…..Loop.
5,10,15,…90

Cls
For I = 5 to 90 Step 5
Print I
Next I
End


38) Generate the following numbers using For….Next…..Loop.
10,20,30,40,…100.

Cls
For I = 10 to 100 Step 10
Print I
Next I
End

39)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.

Cls
I = 1
While I<=100
Print I ;
I = I + 1
WEND
END

40)Generate the following numbers using For….Next…..Loop.
2,4,6,8,10….50

CLS
I = 2
While I < =50
Print I;
I = I + 2
WEND
END




41)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.
1,3,5,7,9,…99


CLS
I = 1
While I <=99
Print I;
I = I + 2
WEND
END




42)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.
1,4,9,…upto 10th term.


CLS
I=1
While I < =10
Print I^2;
I = I + 1
WEND
END


No comments:

Post a Comment

MCQ Question Bank Microsoft PowerPoint