Qbasic Example Programs

Embed Size (px)

Citation preview

  • 7/24/2019 Qbasic Example Programs

    1/10

    Easy QbasicSearchSaturday, August 14, 2010Q-BASIC PROGRAMS

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

    CLSInput 'Enter you name';n$Print 'The name is';n$End

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

    CLSInput " Enter the name ";N$Input " Enter the city";C$Input " Enter the country";CO$Input " Enter the age";APrint " The name is ";N$Print " The city is ";C$Print " The country is ";CO$Print " The age is ";AEnd

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

    ClsInput " enter the length " ;lInput " enter the breadth " ;blet A = l*bPrint" the area of rectangle=" ;aEnd

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

    ClsInput " enter the base" ;bInput " enter the height" ;hlet T = 1/2*b*hPrint" The area of triangle=" ;T

  • 7/24/2019 Qbasic Example Programs

    2/10

    End

    5)Write a program to find the area of the circle.

    ClsInput" Enter the radius " ;RLet C=22/7*R^2Print " The area of circle =" ;CEnd

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

    ClsInput" Enter the radius " ;RLet Circumference=22/7*R*2Print " The area of circle =" ;Circumference

    End

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

    ClsInput" Enter the number" ;nLet square= n^2Print" The area of square=" ;SquareEnd

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

    ClsInput" Enter the number" ;nLet square= n^2Let Cube = n^3Print" The area of square=" ;SquarePrint" The area of cube=" ; Cube

    End

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

    ClsInput " enter the length " ;l

  • 7/24/2019 Qbasic Example Programs

    3/10

    Input " enter the breadth " ;bInput " enter the height " ;hLet Volume= l*b*hPrint" The volume of box =" ;VolumeEnd

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

    CLSInput"Enter the weight in kilogram";KLet P=K*2.2Print "The pound is ";PEnd

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

    ClsInput"Enter the length in kilometer";KLet M= K / 1.6

    Print "The length in miles =";MEnd

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

    ClsInput " Enter the length in miles";MLet K=M*1.6Print" The length in kilo miles=";KEnd

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

    CLSInput "Enter the Initial Mileage";M1Input "Enter the Final Mileage";M2Let D= M2-M1Print " The distance covered=";DEnd

  • 7/24/2019 Qbasic Example Programs

    4/10

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

    ClsInput " Enter the Principal";PInput " Enter the Rate";RInput " Enter the Time";TLet I = P*T*R/100Print " The simple Interest = ";IEnd

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

    ClsInput " Enter the Principal";PInput " Enter the Rate";RInput " Enter the Time";TLet I = P*T*R/100Let A= P + IPrint " The simple Interest = ";I

    Print " The amount=";AEnd

    16)Write any number and find it's half.ClsInput "Enter the desired number "; NLet H = N/2Print "The half of the number = ";HEND

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

    ClsInput"Enter the height ";HInput"Enter the length "; LInput"Enter the Breadth";BLet A= 2 * H * (L+B)Print " The area of four walls =";AEnd

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

    ClsInput " enter the length " ;lInput " enter the breadth " ;b

  • 7/24/2019 Qbasic Example Programs

    5/10

    Let P=2*(l+b)Print" The perimeter of rectangle=" ;PEnd

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

    ClsInput " Enter any number" ;AInput " Enter any number" ;BInput " Enter any number" ;CLet Sum = A+B+CLet Average =Sum/3Print" The sum=" ;SumPrint" The Average is " ;AverageEnd

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

    .

    CLSInput " Enter any number" ;AInput " Enter any number" ;BLet Sum = A+BLet Difference= A-BLet Product = A*BPrint" the sum =" ;SumPrint" the Difference =" ;DifferencePrint" the Product =" ; ProductEnd

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

    ClsInput" Enter the number " ;AInput" Enter the number " ;BInput" Enter the number " ;CLet Avg= (A+B+C)/3Print" 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

  • 7/24/2019 Qbasic Example Programs

    6/10

  • 7/24/2019 Qbasic Example Programs

    7/10

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

    CLSInput Enter the Indian currency;NLet N = I / 1.6Print the Nepalese currency=;IEnd

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

    CLSInput Enter the number; NIf N>0 ThenPrint The number is positiveElse

    Print The number is negativeEndIfEnd

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

    ClsInput Enter any number;N

    R=N mod 2Select case RCase = 0Print The number is Even numberCase ElsePrint The number is odd numberEnd SelectEnd

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

    ClsInput Enter the numbers between 1-3;NSelect case NCase 1Print Its number 1;Case 2Print Its a number 2;Case 3

  • 7/24/2019 Qbasic Example Programs

    8/10

    Print Its a number 3Case elsePrint Its out of range;End selectEnd

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

    ClsInput Enter the alphabet;A$A$=UCase$ (A$)Select Case A$Case APrint Its alphabet ACase ElsePrint Its not alphabet AEnd SelectEnd

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

    ClsInput Enter Letters/Alphabet;A$A$ = UCase $ (A$)Select case A$Case A, E, I, O, UPrint Itsa vowel

    Case ElsePrint Its not a vowelEnd SelectEnd

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

    CLS

    For I = 1 to 50 Step 1Print INext IEnd

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

    Cls

  • 7/24/2019 Qbasic Example Programs

    9/10

    For I = 1 to 99 Step 2Print INext IEnd

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

    ClsFor I = 2 to 50 Step 2Print INext IEnd

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

    ClsFor I = 1 to 99 Step 2

    Print INext IEnd

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

    ClsFor I = 5 to 90 Step 5

    Print INext IEnd

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

    ClsFor I = 10 to 100 Step 10

    Print INext IEnd

    39)Write a program to print numbers stated below USING WHILEWEND STATEMENT.

  • 7/24/2019 Qbasic Example Programs

    10/10

    ClsI = 1While I