# BASIC PROGRAM TO FIND THE SQUARE ROOT, ROUND UP TO AN INTEGER, COSINE AND TANGENT OF GIVEN ANGLES

**1) BASIC program to find the square root of numbers**

To find the square root of a number using BASIC programming language, you can use the built-in mathematical functions. Here’s an example program that calculates the square root:

```
10 PRINT "Enter a number:"
20 INPUT N
30 S = SQR(N)
40 PRINT "The square root of "; N; " is "; S
50 END
```

In this program, the user is prompted to enter a number, which is stored in the variable **N**. The **SQR** function is then used to calculate the square root of** N**, and the result is stored in the variable **S**. Finally, the program prints out the original number and its square root.

2) **BASIC program to find square root of S, round up to an integer:**

To find the square root of a number** S** and round it up to the nearest integer, you can use the **INT** function in BASIC. Here’s an example program:

```
10 PRINT "Enter a number:"
20 INPUT S
30 R = INT(SQR(S) + 0.5)
40 PRINT "The square root of "; S; " rounded up is "; R
50 END
```

In this program, after taking input from the user and storing it in the variable **S**, we calculate the square root using **SQR** function. To round up the result, we add **0.5** to it and then use the **INT** function to truncate any decimal places. The rounded-up value is stored in the variable **R**, which is then printed out.

**3) BASIC program to find cosine of known values:**

To find the cosine of a known value, you can use the **COS** function in BASIC. Here’s an example program:

```
10 PRINT "Enter an angle in degrees:"
20 INPUT A
30 C = COS(A * 3.14159 / 180)
40 PRINT "The cosine of "; A; " degrees is "; C
50 END
```

In this program, the user is prompted to enter an angle in degrees, which is stored in the variable** A**. The **COS** function is then used to calculate the cosine of **A**. Note that since the **COS** function expects the angle to be in radians, we convert it from degrees to radians by multiplying with **3.14159 / 180**. The result is stored in the variable C and printed out.

**4) BASIC program to find tangent of given angles:**

To find the tangent of a given angle, you can use the TAN function in BASIC. Here’s an example program:

```
10 PRINT "Enter an angle in degrees:"
20 INPUT A
30 T = TAN(A * 3.14159 / 180)
40 PRINT "The tangent of "; A; " degrees is "; T
50 END
```

In this program, after taking input from the user and storing it in the variable **A**, we use the **TAN** function to calculate the tangent of **A**. Similar to finding cosine, we convert the angle from degrees to radians by multiplying with **3.14159 / 180**. The result is stored in the variable **T**, which is then printed out.

**5) Plotting a Sine Wave Curve**

Plotting a sine wave curve in BASIC can be achieved by calculating the sine of various angles and displaying them graphically. Here’s a basic example program:

```
10 FOR X = 0 TO 360 STEP 10
20 Y = SIN(X * (PI / 180))
30 PRINT STRING(Y * 50 + 50, "*")
40 NEXT X
50 END
```

In this program, a loop iterates through angles from 0 to 360 degrees with a step of 10 degrees. The `SIN`

function is used to calculate the sine of each angle, which is then scaled and displayed graphically using asterisks.