Write a BASIC program in GW BASIC to input a number. Print all the factors of the number.
Answers
Answer:
stand for Beginners All-purpose Symbolic Instruction Code, the GW in GW-BASIC stands for Gee Whiz (which means Surprised) sometimes it is also said that GW is named after Greg Whitten (former Microsoft Chief Software Architect) who developed the translator for BASIC.
Basics of BASIC –
Just like any other programming language BASIC has certain building blocks which are used to develop programs. Those building blocks are –
Constants
Variables
Operators and
Commands
Constants – A constant is a term or value that does not change during program execution. There are two types of constants in GW-BASIC
Numeric Constant
Alpha-Numeric Constants
Numeric constants are numbers that can be either positive, negative or zero and can also be fractional numbers expressed with decimal point. E.g. 656, – 26, 3.14, 9.8, 0.0 etc…
Alpha-Numeric Constants also known as String constants is a sequence of valid BASIC characters enclosed within a pair of double quotes. They may include alphabets, special characters, numbers or sentences. E.g. “Linkin Park”, “*123#”, “A”, “65536” etc…
Variables – A variable is a memory location to store a constant. The value of a variable can change during the execution of a program. A variable allocates a space inside the physical memory of the computer (RAM) to store a value. A variable must start with an alphabet and can be maximum 8 characters long. There are two types of variables in BASIC –
Numeric Variable
Alphanumeric Variable
Numeric Variables can store only numeric constants. They can have a maximum length of 8 characters which can be both alphabets and numbers but they must begin with an alphabet and not a number. E.g. N, VAL1, AREA, G, PI etc…
Alphanumeric Variables are used to store strings, these variables can also have a maximum length of 8 characters which can be both alphabets and numbers (must begin with an alphabet) but they must end with a $ sign. E.g. A$, ABC$ N1$ etc…
Operators – These are special symbols that are used for specific purpose. Operators are of 3 different types in BASIC
Arithmetic Operators
Logical Operators
Relational Operators
Arithmetic Operators are used to perform mathematical calculations on numeric quantities.
+ for Addition
– for subtraction
* for multiplication
/ for division
^ for exponentiation
Answer:
10 cls
20 input "enter a no.";n
30for i = 1 to n
40 if n mod i = 0 then print i
50 next i
60 end