Simple Calculator more than you expect from school teacher!!!

Please click below to obtain (download) source program file.
Open that file is QBASIC.
.Download Link is:
download calculator.bas files
This program looks like simple desktop calculator, ya you can't use mouse, though numeric keypads will work well to do calculations. See how is this calculator functions. I have made the coding as simple as possible so that you can follow the code and understand it easily.
If you want do more scientific calculations, you may try yourself at home. It will be fun to do programming, believe me.
Enjoy your programming.

Procedural vs. Object-Oriented

Lets understand the basic difference between Procedural

Programming Paradigm and Object-Oriented Programming

Paradigm.

QBASIC MATRIX

This program in QBASIC simple. This program displays the

matrix code which is similar to shown in the movie "MATRIX" .

Lecture 1 | Programming Paradigms 1 (Stanford)


Understand Programming Paradigm

Introduction to Procedural Programming - Part III

In this post I will discuss "How To" Procedular Programming.
Lets begin.
We know that programming is logical arrangement of statements (code) targed to obtain certain goal. Every code (statement) except to non-executable are meant to perform certain action. In procedural programming we will segment (divide) these blocks into several manageable parts (procedures/sub-program). For example, a problem of testing where a number is prime, we will write around 7-8 lines code of program; we can think this problem in procedural way- first there is need of a procedure which accepts a input number and second the number is passed  in another procedure which operates number in testing whether number is prime and returns result then finally there is a need of third procedure which will provide the result (output) to the user.
Here students may find little difficult or misleading or may think in different way. I want to aware you that how would you segment programs into several procedure depends I don't say you will be wrong; ya in the beginning it may be little confusion, but not get overloaded. Slowly with revisions and illustration programs you will finally grab the concepts and then onward it will be habitual.
Lets take a look on above illustration in the form of program (if you don't understand program don't get upset; only try to catch concept of procedures):

Program: testing whether number is prime (structure program- no procedures)
CLS
REM asking user to input a number to test for prime
INPUT "Enter a testing number"; n
REM test whether number is prime; set flag f to 1 (we first assume that n is prime)
f=1
FOR i=2 TO n/2
  IF n mod i=0 THEN f=0 : EXIT FOR
NEXT i
REM check value of f to decide prime/composite and display result to the user
IF f=1 THEN
  PRINT n;" is Prime Number!"
ELSE
  PRINT n; " is Composite Number!"
ENDIF
END

Program: testing whether number is prime (Procedural - 1 sub-routines and 2 function)
[Here. ACCEPT function askes testing number and returns to module (calling program)
 ISPRIME function with a value passed through parameter returns 1 if the value is prime
 DISPLAY sub-routine will display the result on the screen]
DECLARE FUNCTION accept()
DECLARE FUNCTION isPrime(num)
DECLARE SUB display(testnum, result)
CLS
v=accept
REM isPrime function is invoked then its return is passed to the display (see more-Functional Operator)
CALL display(v, isPrime(v))
END

FUNCTION accept
INPUT "Enter a testing number="; n
accept=n
END FUNCTION

FUNCTION isPrime(num)
f=1
FOR i=2 TO num/2
  IF num MOD i=0 THEN f=0 : EXIT FOR
NEXT i
isPrime=f
END FUNCTION

SUB display(testnum, result)
IF result=1 THEN
  PRINT testnum;" is Prime!"
ELSE
 PRINT testnum;" is Composite!"
ENDIF
END SUB

For more see upcoming post.
Best wishes!!!

Introduction to Procedural Programming in QBASIC - Part II

In my last post I had briefly discussed about procedure programming. Hope that might have enlightened your knowledge of Procedural Programming in QBASIC. Today I will discuss, its significance, need and benefits.
I would like to start with a very popular verse, "Divide and Conquer"- this was practised by British Empire in 19th and 20th century; you might have learned in History. We know this didn't sustain British Empire but believe me when you practice this in programming (viz. are procedural or modular programming approach) you will feel more comport in writing larger size program after you understand and learn the technique.

With the advent of development and progress in the technology; faster and high-end processors development made developer think larger problems to be solved through programming. When such time came then structure programming failed and brought new difficulties in writing larger sized programs. There were lots of hards like complexities in debugging, repetition of codes, unmanageable codes, unnecessary growth in size of programs and primarily non-integrity codes were the major problems. There was also need of newer methodology of programming and mean time new dimension in the field of programming was introduced i.e. Procedural Programming Approach (often considered as modular programming in general words but keep it in mind the module (modular) and procedure (procedural) are different in the context of QBASIC. Procedure is small-size division whereas as Module is large-size division but both of them are division of blocks of code into very manageable form).
A whole program is breaked (synthesized) into manageable small segments (procedures/subprogram) either functions or sub-routine procedures according to need so that there is reusability of these procedures. From this line importance of procedures can be easily estimated. Let us outline these importance or benefits of procedure (procedural) programming approach:
  (i) Manageable size of code from division into several segments
  (ii) Reusability of codes which reduces size of program by significantly reducing lines of codes without  degrading performance rather optimizing performance.
  (iii) Higher integrity in the codes as there is nearly zero repetition of same set of codes
  (iv) Larger sized programs easy to develop, debug and maintain.

Though this is not enough so many new paradigm of programming are introduced recently and pracised worldwidely but you can say they follow procedural approach with futher enhancements and features.

At last but not least we must admit that procedural programming paved a strong cornerstone in the field of programming.

Hope you enjoyed reading this post. In next post you can find terms and terminologies, statements and functions of QBASIC associated with procedural programming and also how to write procedure programs.

Till then bye. Have a good time!!!