0% found this document useful (0 votes)
14 views2 pages

4863 - Basic Programming II

Basic Programming introduces fundamental programming principles and techniques for beginners. It covers built-in functions, basic notations such as variables and constants, and control structures. An example program demonstrates how to compute the roots of a quadratic equation based on user-provided coefficients.

Uploaded by

lukaisa672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

4863 - Basic Programming II

Basic Programming introduces fundamental programming principles and techniques for beginners. It covers built-in functions, basic notations such as variables and constants, and control structures. An example program demonstrates how to compute the roots of a quadratic equation based on user-provided coefficients.

Uploaded by

lukaisa672
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basic Programming II

Introduction to Basic Programming:


Basic Programming refers to the fundamental principles and techniques used in computer
programming. It is often the starting point for beginners to learn programming concepts and
syntax.
Built-in Functions:
Built-in functions are pre-defined functions provided by the programming language that perform
specific tasks. In Basic Programming, some common built-in functions include:
. PRINT: Used to display output on the screen.
. INPUT: Used to accept input from the user.
. SUM: Computes the sum of two or more numbers.
. SIN, COS, TAN: Computes trigonometric functions.
. ABS: Computes the absolute value of a number.
. LEN: Computes the length of a string.
. INT, FLOAT: Converts values to integers or floating-point numbers.
Basic Notations:
. Variables: Symbols used to store data values. They can be assigned different values
5
throughout the program.
. Constants: Fixed values that do not change during the execution of a program.
4
. Operators: Symbols used to perform arithmetic, logical, or relational operations.
3
. Control Structures: Constructs used to control the flow of execution in a program, such as
2
loops and conditional statements.
. Comments: Text added to the code for documentation purposes. They are ignored by the
1
compiler or interpreter.
Writing a Basic Program to Compute an Algebraic Equation:
7
Let's write a Basic program to compute the value of a quadratic equation ax^2 + bx + c = 0,
6
where a, b, and c are coefficients provided by the user.
5
Example;
4
10 PRINT "Enter coefficients for the quadratic equation ax^2 + bx + c = 0"
3
20 INPUT "Enter coefficient a: ", a
2
30 INPUT "Enter coefficient b: ", b
1
40 INPUT "Enter coefficient c: ", c
50 LET discriminant = b^2 - 4*a*c
60 IF discriminant > 0 THEN
70 LET x1 = (-b + SQR(discriminant)) / (2*a)
80 LET x2 = (-b - SQR(discriminant)) / (2*a)
90 PRINT "Two real and distinct roots: x1 =", x1, "and x2 =", x2
100 ELSEIF discriminant = 0 THEN
110 LET x = -b / (2*a)
120 PRINT "One real root: x =", x
130 ELSE
140 PRINT "No real roots, roots are complex"
150 END IF

This program first prompts the user to input the coefficients a, b, and c. It then calculates the
discriminant of the quadratic equation and checks its value to determine the nature of the roots.
Finally, it prints the roots accordingly.

You might also like