# BASIC was, well… basic

The BASIC programming language was so called because it was meant to be easy to learn , and easy to use.

BASIC descended from Fortran, with the same simple structure and an avoidance of nesting and recursion. The first version of BASIC had remarkably few statements: LET, PRINT, END, FOR, NEXT, GOTO, IF THEN, DEF, READ, DATA, DIM, GOSUB, RETURN and REM. The distinction between integer and real variables was abolished and variable were restricted to names consisting of a single letter or a single letter and a digit. The simplicity of BASIC made it easy for novice programmers to learn.

Consider the following example BASIC program that calculates accrued interest:

```10 INPUT "principal"; P
20 INPUT "interest rate"; R
30 INPUT "no of periods per year"; NP
40 INPUT "years"; YRS
50 I = P * ((1+R/(100*NP))^(NP*YRS)-1)
60 PRINT "total interest =" I```

Here is the same program in C:

```#include <stdio.h>
#include <math.h>
int main(void)
{
double p, r, np, yrs, i;
printf("principal? ");
scanf("%lf", &p);
printf("interest rate? ");
scanf("%lf", &r);
printf("no. of periods per year? ");
scanf("%lf", &np);
printf("years? ");
scanf("%lf", &yrs);
i = p*(pow(1+r/(100*np),np*yrs)-1);
printf("total interest = %lf\n", i);
return 0;
}
```

This illustrates many of the differences between the two languages. The most apparent is that BASIC uses line numbers, C doesn’t. But the BASIC program is 6 lines long, the C program is 17. The C program uses two lines to achieve input from the user, one for the prompt, one for actually reading in the value. The BASIC program uses one line.

BASIC was successful in the 1980s due to the personal computer. Most personal computers of the time had a ROM-resident BASIC interpreter. The Apple II, PET 2001 and TRS-80 all used BASIC as their core programming language when released in 1977.