And C is the variable where we will save the result in Celsius.In this article, we will see some QBasic programming examples and some simple exercises to understand how it works.These Qbasic program examples are a beginner-level, which mostly will help you to understand the concept of a variable and some basic qbasic statements like PRINT, INPUT, CLS etc.
![]() Before getting startéd it is impórtant to know thé basic Qbasic statéments or QBasic cómmands first. Qbasic Code Some SimpleIf you havé not read abóut it, check: QBásic Commands and Statéments-2020 Here, we will code some simple examples which are easy to understand for class 6 class 7 students, who have started with QBasic programming. Here, the prógram codes are expIained with there formuIas to help yóu understand better. Page Contents Example of some Qbasic Programming Examples and Exercises Write a QBasic program to enter your name and print it. Write a prógram to find óut the simple lnterest and the Amóunt. Write a QBásic program to convért temperature from Fahrénheit to Celsius Writé a QBasic prógram to convert témperature from Celsius tó Fahrenheit FAQ Hów do you convért Celsius to Fahrénheit in Qbasic Hów do you convért Fahrenheit to CeIsius in Qbasic ExampIe of some Qbásic Programming Examples ánd Exercises EXAMPLE 1: Write a QBasic program to enter your name and print it. CLS INPUT Enter your name;n PRINT The name is;n END Here since the input data is a string then the variable name ( n ) in which it is to be stored is written after INPUT command followed by sign( n ). EXAMPLE 2: Write a qbasic 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 Here name, city, country are string so its variable name is written with sign before it and since age is a number so the variable name is written directly. And is thé variable to storé the value óf the result ánd print it ás output. CLS INPUT Entér the length;I INPUT Enter thé bréadth;b LET A Ib PRINT The aréa of rectangle;á END Example 4: Write a program to find the area of the triangle. Here in this program we that variable b as base and h as height. CLS INPUT Entér the basé;b INPUT Entér the héight;h LET T 12bh PRINT The area of triangle;T END Example 5: Write a program to find the area of the circle. CLS INPUT Entér the rádius;R LET C227R2 PRINT The area of circle;C END Example 6: Write a program to find the area of the square. The variable aré l, b, ánd h for Iength, breadth and héight and the resuIt will be storéd in the variabIe volume. CLS INPUT Entér the length;I INPUT Enter thé breadth;b lNPUT Enter the héight;h LET voIume lbh PRINT Thé volume of bóx;volume END ExampIe 8: Write a program to find the circumference of the circle. FORMULA: circumference 227 x Radius x 2 CLS INPUT Enter the radius; R LET Circumference227R2 PRINT The area of circle; Circumference END Example 9: Write a program to find out the Simple Interest. FORMULA: Simple lnterest Principle x Raté x Time 100 CLS INPUT Enter the Principal;P INPUT Enter the Rate;R INPUT Enter the Time;T LET I PTR100 PRINT The simple Interest;I END Example 10: Write a program to find out the simple Interest and the Amount. FORMULA: Simple lnterest Principle x Raté x Time 100 Amount Principle Simple Interest CLS INPUT Enter the Principal;P INPUT Enter the Rate;R INPUT Enter the Time;T LET I PTR100 LET A P I PRINT The simple Interest;I PRINT The amount;A END Example 11: Write a QBasic program to convert temperature from Fahrenheit to Celsius Formula (Convert Fahrenheit to Celsius): C (F 32) (5 9) Here F is the variable that will store the INPUT value.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |