Home > Basic Programming > What I’ve been working on for the past week ‘-‘

What I’ve been working on for the past week ‘-‘

Qbasic Tutorial 6 -User Input-

Declare Varible Num2 as Integer

Program Asking the user to input their first and last name

So 2 variables one called FirstName and the second called LastName

Declare FirstName as a string as well with the LastName

Get the user input by placing the command INPUT then the actual prompt ex.”Enter First Name: “

Ex. Input “Enter First Name: “, FirstName     Input “Enter Last Name: “, LastName

Note-If you replace the commas here with ; it places a ? after Enter First Name

print the output “Nice to meet you, ” ; FirstName; ” ” ; LastName

Then we modify the program to ask the user to enter 2 numbers so you can add them together.

This is done by declaring Num1 as an Integer by:

DIM Num1 AS INTEGER

Doing the same for the second variable Num2

DIM Num2 AS INTEGER

Now we get the input from the user promting the user to enter the first integer.

Doing this by Input “Enter First Integer: “, Num1

Same with the second integer

Input “Enter Second Integer: “, Num2

Now we print the output as:

Print Num1; ” + “; Num2; ” = “; Num1 + Num2

Example: So is the user enters in 10 as the first number and 20 as the second variable. We would get 10 plus 20 = 10 plus 20 (the actual calculation)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: