Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, November 30, 2022

QBASIC program to input days and convert into year months and days

 QBASIC program to input days and convert into year months and days

 




Introduction:

QBASIC is a popular programming language used for developing small and medium-sized applications. It is known for its simplicity and ease of use, making it an excellent choice for beginners to learn programming concepts. One of the interesting programs that can be created using QBASIC is converting days into years, months, and days. In this blog article, we will discuss how to write a QBASIC program to input days and convert them into years, months, and days.

Body:

To write a QBASIC program that converts days into years, months, and days, we first need to understand the formula for calculating these values. The following formula can be used:

years = days / 365 
months = (days mod 365) / 30 
days = (days mod 365) mod 30

Using this formula, we can write a QBASIC program that takes input from the user in the form of days and converts them into years, months, and days. We can achieve this by using simple input and output statements, along with some mathematical calculations.


In the program, we can prompt the user to enter the number of days they want to convert. Once the user enters the value, we can use the formula mentioned above to calculate the number of years, months, and days. Finally, we can display the converted values to the user using output statements.


Coding:


INPUT "enter days"; d
yr = d \ 365
d1 = d MOD 365
mth = d1 \ 30
day = d1 MOD 30
PRINT yr; "Years"; mth; "Months"; day; "Days"
END


By using SUB procedure (SUB…END SUB)

DECLARE SUB cal (d)
CLS
INPUT "enter days"; d
CALL cal(d)
END

SUB cal (d)
yr = d \ 365
d1 = d MOD 365
mth = d1 \ 30
day = d1 MOD 30
PRINT yr; "Years"; mth; "Months"; day; "Days"
END SUB

 


Output:




Conclusion:

In conclusion, QBASIC is an excellent language for beginners to learn programming concepts. Writing a program to convert days into years, months, and days is a great way to practice programming skills in QBASIC. By using the formula mentioned above, we can write a QBASIC program to input days and convert into year months and days. This program is not only useful but also a fun way to practice programming skills.


You can also Read:


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages