Basic Language System Commands

Continuation from "More on understanding basic language

SOME SYSTEM COMMANDS

 These commands are used without line numbers. They are executed as soon as we press the Enter Key. They are also called direct mode commands.

1. REM: REM is a short form of Remark; It is used to give heading for the program. It is a non-executable command. REM command can be given anywhere in the program.

SYNTAX
LineNo REM Comment

E.g.
10 REM This is a program for print 2 numbers
20 PRINT 5, 6
30 REM Now we can add the numbers
40 PRINT 5 + 6
50 END
RUN

OUTPUT
5      6
11
OK

2. CLS: CLS is a command used for clearing the screen. This command wipes out whatever is displayed on the monitor.

SYNTAX
CLS

E.g.
10 PRINT 4
20 PRINT 8
30 PRINT “JOHN”
40 END
RUN

OUTPUT
4
8
JOHN
OK
CLS
After CLS Command, the screen becomes clear of all data.

3. RUN: RUN Command tells your computer to read the program instructions and execute them. To execute RUN command, press the function key F2.

SYNTAX
RUN

E.g.
10 PRINT “LET”
20 PRINT “US”
30 PRINT “GO”
40 END
RUN
OK

OUTPUT
LET
US
GO

4. LIST: LIST command lists out all the instructions stored in the computer’s memory. It arranges a program in the ascending order and displays all the instructions. To execute RUN command, press the function key F1.

SYNTAX
LIST LineNo

E.g.
10 PRINT “WILLIAM”
20 PRINT “BERNAD”
15 PRINT “SHAKESPEARE”
25 PRINT “SHAW”
LIST

OUTPUT
10 PRINT “WILLIAM”
15 PRINT “SHAKESPEARE”
20 PRINT “BERNAD”
25 PRINT “SHAW”

5. NEW à New command wipes the old program from the computer’s memory. It is food practice to type NEW and press ENTER key before starting a NEW program.

SYNTAX
NEW

6. DELETE: As the name indicates, this command is used to remove any unwanted line from your program.
SYNTAX
DELETE

E.g.
10 PRINT 5
20 PRINT 3
30 PRINT 10
40 END
         
One line can be removed by typing DELETE 20.
Line no 20 will be removed from the memory.
Now LIST command should be used to view the program
10 PRINT 5
30 PRINT 10
40 END

POINTS TO REMEMBER


1. REM or REMARK statement is used as the heading of the title of the program
2. CLS command is used to clear the screen.
3. NEW command clears the program form the memory of the computer.
4. DELETE command is used to remove any line from the program.
5. RUN command executes the program.


More on "Understanding Basic Language "


This is a continuation from: Understanding Basic Language

Mathematical Operators
To carry out arithmetic operations in programming language, mathematical operators are used. Some of these operators are given below:

Operations        Operator
Addition               +
Subtraction           -
Multiplication       x
Division                /
Greater than          >
Lesser than           <
Exponential          ^
Non equal            <>

Expressions

An expression is something the interpreter calculates (or evaluates).
Some examples given below:
A = 24
B = 25
C = A + B (returns 49)

A = 120
B = 12
C = A / B (returns 10)

A = 34
B = 26
C = A - B (returns 8)


A = 200
B = 100
C = (A * 3) + B (returns 700)

A = 3
B = 2
C = A ^ B (returns 9)

 

Evaluate the following:


100 + 50/2 =
100 + 5 – 90 =
82 – (3 x 20 + 4) =
32 – 23 =
40 / 21 + (20 – 2) =

When the Basic Interpreter is loaded into the memory of the computer, the Basic Interface screen will open.


Type your first program:

10 PRINT “Welcome to the World of BASIC”

Press F2 to run the program. You will see the output as follows:

Press any key to return to the main screen.

Some Important Commands- A command tells the Basic Interpreter to perform a certain task.

PRINT: The PRINT command tells the Interpreter to print something on the screen. In the above case the interpreter prints – “Welcome to the World of Basic”.

Try the following examples

PRINT 5 + 10 * 2
25

PRINT “ROSE & LOTUS”
ROSE & LOTUS

PRINT “COMPUTER”
COMPUTER
                   
PRINT 3 ^ 2 * 5
45

PRINT “SACHIN”                                                 
SACHIN

PRINT “Rahul” ; “Dravid”
RahulDravid

PRINT “Rahul” , “Dravid”
Rahul Dravid
If a List of Instructions has to be given, line numbers will have to be used.

Try the following examples:

10 PRINT 100
20 END
RUN
100
OK

10 PRINT 15
20 PRINT 15 + 15
30 END
RUN
15
30
OK

10 PRINT “THE LOST”
20 PRINT “WORLD”
30 END
RUN
THE LOST
WORLD
OK

10 PRINT “ROHIT”
20 END
30 PRINT “RAM”
RUN
ROHIT
OK

END: The last statement of a program is END. END terminates the program. It means that the program is complete and the computer will ignore any line number given after the END statement.



POINTS TO REMEMBER
- PRINT statement displays anything written after it. It may be data or result.
- END statement is used to terminate the program.
- Once program is over, RUN command is given to execute the program.
- When a Computer has to do more than one calculation then it follows BODMAS Rule.

B à Brackets
O à Of
D à Division
M à Multiplication
A à Addition
S à Subtraction

State “True” or “False”
1) PRINT command cannot be given with line numbers.
2) For division we use “ / “ sign.
3) Non-Numeric data is displayed as it is.
4) The computer will ignore any line number given after END statement.
5) Non-Numeric information is written in double quotation marks.

Understanding Basic Language

What is a Program?

A computer can be given instructions in the form of a program. Program is a very common word in your day-to-day life also. For e.g. to post a letter you will
1. Get ready
2. Go to Post Office
3. Give money to the Post Master for stamp
4. Take stamp and fix it on the envelope
5. Post the letter in the letter box
6. Come back home

Here, set of instructions are listed step wise to post a letter. It means that a program was set for you. A set of instructions is called a program. 
We give data and instructions to the computer to do any task. We can define a computer program, as a set of instructions given to a computer to get desired result.

Need for a Programming Language

A language that is encrypted in binary numbers or a language similar to binary numbers that a computer’s hardware understands is understood more speedily by the computer. Languages that use English like statements are easier for programmers to use, but they have to be translated first so that the computer can understand it.
The person who writes the program for computer is known as Programmer and programs are known as Software. A computer follows the instructions given by the programmer to perform a specific job. To perform a particular task, a programmer prepares a sequence of instructions known as program, which is written in a programming language.

Program: A set of instructions given to the computer to execute a task is known as program and the process of writing is called programming. A person who writes programs is called a programmer.

BASIC - Beginners’ All Purpose Symbolic Instruction Code was developed by John G Kemeny and Thomas E Kurtz at Dartmouth College in U.S.A. in 1964. It is one of the simplest and easy to use computer languages. Basic is a High Level Programming Language, also termed as the Interpreter which reads one statement of a program at a time and executes appropriate instructions leading to some computations.
Basic is an interactive language, meaning it allows interactive communication between the user and the computer during the execution of programs.
Like other languages, computer languages also have grammar. Grammar used for any computer language is known as Syntax of that language.
We have to follow some rules and these rules are known as Syntax rules. While writing a program if we make a mistake in the syntax, then computer displays error message “Syntax Error”.
                                                                                                                            

Syntax Rules of Basic



1. Basic Program is made up of lines or statements. A new statement should be written on a new line.
2. All statements should have a line number.
3. Line number should be a positive integer (whole number).
4. No two statements can have the same line number.
5. Line number should be followed by Basic command.
6. Statements are executed in ascending order only.
7. Program should end with END command. END command should have the highest line number. Any line number after the END will be ignored.
8. Usually line numbers are given in the multiples of 10s.

We have to provide data to the computer in the form of a program. Data are made up of different characters.

Characters: Any sign or symbol is known as a character. The basic character set is made up of Alphabets, Numbers, and Special signs. For e.g. A to Z, 0 to 9, # “ $ etc. Blank space is also considered as a character.

Data: Data is a fact. Data consists of character set. Data is processes to get information. Processed data is called result. Data is of two types: Numeric and Non-Numeric.

Numeric: This information has only numbers. These numbers can be positive, negative, fractional or integer. Information regarding age, time, height, weight will always be a number. Numeric data is used for mathematical calculations e.g. 45. 67.7. 34x4, 89+4 etc.

Non-numeric: This information consists of numbers, alphabets or any other special sign. Non numeric information is generally written in quotation marks in the computer programs. With non-numeric information one cannot do Mathematical calculation. E.g.”Roshan” , “45 apples “ , “ $%”.

Process: Process means work done on the information.

Result: The processed data are called result.            NEXT PAGE>>

Memtransistor' brings world closer to brain-like computing

This below article is form the www.sciencedaily.com website.

Computer algorithms might be performing brain-like functions, such as facial recognition and language translation, but the computers themselves have yet to operate like brains.

"Computers have separate processing and memory storage units, whereas the brain uses neurons to perform both functions," said Northwestern University's Mark C. Hersam. "Neural networks can achieve complicated computation with significantly lower energy consumption compared to a digital computer."

In recent years, researchers have searched for ways to make computers more neuromorphic, or brain-like, in order to perform increasingly complicated tasks with high efficiency. Now Hersam, a Walter P. Murphy Professor of Materials Science and Engineering in Northwestern's McCormick School of Engineering, and his team are bringing the world closer to realizing this goal

CONTINUE READING >>>>

Artificial intelligence

The modern definition of artificial intelligence (or AI) is "the study and design of intelligent agents" where an intelligent agent is a system that perceives its environment and takes actions which maximizes its chances of success.

John McCarthy, who coined the term in 1956, defines it as "the science and engineering of making intelligent machines."

CONTINUE READING >>

Computer Memory

Memory is major part of computers that categories into several types. Memory is best storage part to the computer users to save information, programs and etc, The computer memory offer several kinds of storage media some of them can store data temporarily and some them can store permanently. Memory consists of instructions and the data saved into computer through Central Processing Unit (CPU).

The performance of computer mainly based on memory and CPU. Memory is internal storage media of computer that has several names such as majorly categorized into two types, Main memory and Secondary memory.

1. Primary Memory / Volatile Memory:

Primary Memory also called as volatile memory because the memory can’t store the data permanently. Primary memory select any part of memory when user want to save the data in memory but that may not be store permanently on that location. It also has another name i.e. RAM.

Random Access Memory (RAM):

The primary storage is referred to as random access memory (RAM) due to the random selection of memory locations. It performs both read and write operations on memory. If power failures happened in systems during memory access then you will lose your data permanently. So, RAM is volatile memory. RAM categorized into following types.

DRAM
SRAM
DRDRAM

2. Secondary Memory / Non Volatile Memory:

Secondary memory is external and permanent memory that is useful to store the external storage media such as floppy disk, magnetic disks, magnetic tapes and etc cache devices. Secondary memory deals with following types of components.

Read Only Memory (ROM) :

ROM is permanent memory location that offer huge types of standards to save data. But it work with read only operation. No data lose happen whenever power failure occur during the ROM memory work in computers.

ROM memory has several models such names are following.

1. PROM: Programmable Read Only Memory (PROM) maintains large storage media but can’t offer the erase features in ROM. This type of RO maintains PROM chips to write data once and read many. The programs or instructions designed in PROM can’t be erased by other programs.

2. EPROM : Erasable Programmable Read Only Memory designed for recover the problems of PROM and ROM. Users can delete the data of EPROM thorough pass on ultraviolet light and it erases chip is reprogrammed.

3. EEPROM: Electrically Erasable Programmable Read Only Memory similar to the EPROM but it uses electrical beam for erase the data of ROM.

Cache Memory: Mina memory less than the access time of CPU so, the performance will decrease through less access time. Speed mismatch will decrease through maintain cache memory. Main memory can store huge amount of data but the cache memory normally kept small and low expensive cost. All types of external media like Magnetic disks, Magnetic drives and etc store in cache memory to provide quick access tools to the users.

Beginnners should learn these simple Programming Languages

1. Python

The coolest coding language to learn for the first time beginners is Python. Python is open source and free to use, even for commercial applications. It is usually referred to as a scripting language, allowing programmers to create out large numbers of easily readable and functional code in short periods of time. It’s also dynamic, and supports object-oriented, procedural, and functional programming styles, among others. Python is one of the most widely used high-level programming languages today.

Python is used by companies such as Google, Yahoo! and NASA. Django is the web application framework written by Python, which powers very popular sites such as Instagram, Pinterest and The New York Times.


2. Ruby

Ruby is simple, readable and for people who don’t have any kind of programming experience. Ruby is a dynamic, object-oriented scripting language that is used in the development of websites and mobile apps. It is the language that powers their framework, Ruby on Rails, which is behind websites such as Twitter, Groupon and GitHub. It is also mostly used for backend development, and popular sites such as Airbnb, Shopify, Bloomberg, Hulu, and Slideshare.

When learning Ruby, you don’t have to learn a billion new commands, like in some other coding languages. Its developer, Yukihiro Matsumoto, has designed it to be easy and practical.

It is easy to learn with a helpful 20 minute quick start guide on the official Ruby website. There are a lot of documentation available as well as great resources that will help you to understand Ruby from the very beginning.


3. JavaScript
JavaScript is a primarily client-side scripting language used for front-end development. Java is a programming language while JavaScript is a scripting language. JavaScript is the most commonly used programming language to create cool websites and games for the web. It is dynamic and is flexible to use on object-oriented programming. It derives much of its syntax from The C Language.

It runs on every single platform and is already in your browser for you to start learning, which means you need not install it. If you want to build anything for the web, then JavaScript must be on your list of programs to learn. However, JavaScript is also known to be a difficult language as it is untyped and thus is difficult to debug.


4. Java

Java is one of the most popular and general purpose programming language in the world. It is a class-based, object-oriented language and designed to be portable, which means that you can find it on all platforms, operating systems and devices.

Java is usually used to build Android apps, desktop apps, and video games. It is also commonly used as a server-side language for enterprise-level backend development. In addition, it adds to the capabilities of the C++ language. So, if you already have knowledge of C++, it will help with learning Java.
Java programming is a highly sought after skill, as having knowledge of it opens a lot of avenues in terms of employment. If you want to give it a try, go to Learn Java Online and start with the lessons today.

5. C/C++

C is often used to program system software and is the lingua franca of Operating Systems. C has influenced almost all programming languages, especially C++. So, if you know C well, you would probably have less difficulty picking up other popular languages.
On the other hand, C++ is a powerful language based on C, which has added object-oriented features like classes to the language, along with virtual functions and templates. C++ is another of the world’s most popular programming languages and is designed for programming systems software. It is still widely used to build games/game engines, desktop apps, mobile apps, and web apps. C++ is powerful and fast, which has been used to build software such as Adobe Systems, Amazon, Paypal, Chrome, and more. Much like C, C++ is generally considered harder for beginners to learn on their own. 
x

Overview of Computers

Two systems of computers:
1) PC – the Personal Computer              
2) Mac – the Apple Macintosh.

Two designs of computers:
1) desktop
2) laptop (notebook)

Computer architecture:  
Main components of a computer            Multimedia devices                  Other peripheral devices

1)  computer                                        1)  CD-ROM / DVD drive         1)  printer            
2)  monitor                                          2)  video card                              2)  scanner  
3)  hard disk/ hard drive                      3)  soundcard                              3) CD-recorder,CD-R/CD- RW  4)  keyboard                                        4)  speakers                                4)  modem      
5)  mouse / trackball /                         5)  headphones / headset             5)  USB flash drive                
    touch pad                                        6)  microphone                             6)  webcam            
                                                                                                                 7)  digital camera
                                                                                                                 8)  digital voice recorder
                                                                                                                 9)  camcorder
Inside the Computer

1) Processor:
The CPU (Central Processing Unit), a complete computation engine that is fabricated on a single chip, is the computer’s brain. It is sometimes referred to as the central processor, microprocessor, or just processor. Two typical components of a CPU are: 1) the arithmetic logic unit (ALU), which performs arithmetic and logical operations, and 2) the control unit, which extracts instructions from memory and decodes and executes them, calling on the ALU when necessary.

2) Memory:
ROM (Read Only Memory) is the computer’s permanent, long-term memory. Tere are types of ROM called PROM that can be altered. The P stands for programmable. ROM's purpose is to store the basic input/output system (BIOS) that controls the start-up, or boot process.
RAM (Random Access Memory) is a working area where the operating system (e.g. Windows), programs and data in current use are kept, ready to be accessed by the processor. It is the best known form of computer memory. However, RAM, unlike ROM, is emptied when the computer is switched off. The more RAM you have, the quicker and more powerful your computer is.
There are two basic types of RAM: dynamic RAM (DRAM) and static RAM (SRAM).
The two types differ in the technology they use to hold data. DRAM, the more common type, needs to be refreshed thousands of times per second. SRAM does not need to be refreshed, which makes it faster, but it is also more expensive than DRAM.

Memory is measure in the following units:
-  1 byte = 8 bits (Each 1 or 0 is called a bit (i.e. binary digit). Each character (i.e. a letter, a number, a space, or a punctuation mark) has its own arrangements of 8 bits, e.g. 01000001 = “A”, 01000010 = “B”.
-  1 KB (kilobyte) = 1024 (210) bytes
-  1 MB (megabyte) = 1024 (210) KB
-  1 GB (gigabyte) = 1024 (210) MB
     
Cache (pronounced as "cash") is a buffer (made of a small number of very fast memory chips) between main memory and the processor. It temporarily stores recently accessed or frequently-used data. Whenever the processor needs to read data, it looks in this cache area first. If it finds the data in the cache, then the processor does not need to do more time-consuming reading of data from the main memory. Memory caching allows data to be accessed more quickly.

Storage Devices
The most common forms of storage devices in a home computer are:
- Hard disk drive
- Floppy disk
- CD-ROM
- CD-R and CD-RW
- DVD-ROM
- USB flash drives

Monitor
There are two types of monitors available for PCs: the traditional CRT (cathode ray tube) and the newer LCD (liquid crystal display). The CRT is used for both televisions and computers. It produces a good quality image at a number of different settings for a reasonable price. LCD monitors, also known as flat panel displays, are used in laptop (or notebook) computers and more frequently for desktops as well. They are lighter and smaller (only inches thick) than CRTs with reduced electromagnetic emissions and power consumption.

Video Card
The card here is a jargon for an electronic circuit board. Video cards are also known as graphics cards, which are responsible for displaying 2D and 3D images on your monitor. 2D graphics are the regular pictures and images that appear on your screen while 3D graphics are mostly used in games and imaging.

Sound Card
A sound card is an electronic circuit board that is mounted inside the computer to control sound output to speakers or headphones, to record sound input from a microphone connected to the computer, and to manipulate sound stored on a disk. Sound cards are essential for multimedia applications and have become common on modern personal computers.
Many sound cards are also Windows-compatible. Many multimedia applications require the system to have a Windows-compatible sound card to run properly.

Ports
A port is an interface on a computer to which you can connect a device. Personal computers have various types of ports. Internally, there are several ports for connecting disk drives, monitors, and keyboards. Externally, personal computers have ports for connecting modems, printers, mice, and other peripheral devices.

There are three common types of external ports that usually come with a computer:

1) Parallel ports (for most printers)
2) Serial ports (for most modems and some mice)
3) USB (Universal Serial Bus) ports (for about every peripheral made in a USB version)

Java - Basic Syntax

When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods, and instance variables mean.

Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behavior such as wagging their tail, barking, eating. An object is an instance of a class.

Class − A class can be defined as a template/blueprint that describes the behavior/state that the object of its type supports.

Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.

Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.

Java - Overview

Java programming language was originally developed by Sun Microsystems which was initiated by James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0 [J2SE]).

With the advancement of Java and its widespread popularity, multiple configurations were built to suit various types of platforms.

The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively. Java is guaranteed to be Write Once, Run Anywhere.

Java is 

Object Oriented − In Java, everything is an Object. Java can be easily extended since it is based on the Object model.

Platform Independent − Unlike many other programming languages including C and C++, when Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on whichever platform it is being run on.

Simple − Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it would be easy to master.

Secure − With Java's secure feature it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.

Architecture-neutral − Java compiler generates an architecture-neutral object file format, which makes the compiled code executable on many processors, with the presence of Java runtime system.

Portable − Being architecture-neutral and having no implementation dependent aspects of the specification makes Java portable. Compiler in Java is written in ANSI C with a clean portability boundary, which is a POSIX subset.

Robust − Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.

Multithreaded − With Java's multithreaded feature it is possible to write programs that can perform many tasks simultaneously. This design feature allows the developers to construct interactive applications that can run smoothly.

Interpreted − Java byte code is translated on the fly to native machine instructions and is not stored anywhere. The development process is more rapid and analytical since the linking is an incremental and light-weight process.

High Performance − With the use of Just-In-Time compilers, Java enables high performance.

Distributed − Java is designed for the distributed environment of the internet.

Dynamic − Java is considered to be more dynamic than C or C++ since it is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

History of Java

James Gosling initiated Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called ‘Oak’ after an oak tree that stood outside Gosling's office, also went by the name ‘Green’ and ended up later being renamed as Java, from a list of random words.

Sun released the first public implementation as Java 1.0 in 1995. It promised Write Once, Run Anywhere (WORA), providing no-cost run-times on popular platforms.

On 13 November, 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL).

On 8 May, 2007, Sun finished the process, making all of Java's core code free and open-source, aside from a small portion of code to which Sun did not hold the copyright.

Java String - Programming Examples

1. How to compare two strings in Java ?

2. How to search the last position of a substring ?

3. How to remove a particular character from a string ?

4. How to replace a substring inside a string by another one ?

5. How to reverse a String?

6. How to search a word inside a string ?

7. How to convert a string totally into upper case?

8. How to optimize string concatenation ?

How to optimize string concatenation ?

Following example shows performance of concatenation by using "+" operator and StringBuffer.append() method.

public class StringConcatenate {
   public static void main(String[] args) {
      long startTime = System.currentTimeMillis();
     
      for(int i = 0;i<5000 i="" p="">         String result = "This is"
            + "testing the"
            + "difference"+ "between"
            + "String"+ "and"+ "StringBuffer";
      }
      long endTime = System.currentTimeMillis();
      System.out.println("Time taken for string"
         + "concatenation using + operator : "
         + (endTime - startTime)+ " ms");
      long startTime1 = System.currentTimeMillis();
     
      for(int i = 0;i<5000 i="" p="">         StringBuffer result = new StringBuffer();
         result.append("This is");
         result.append("testing the");
         result.append("difference");
         result.append("between");
         result.append("String");
         result.append("and");
         result.append("StringBuffer");
      }
      long endTime1 = System.currentTimeMillis();
      System.out.println("Time taken for String concatenation"
         + "using StringBuffer : "
         + (endTime1 - startTime1)+ " ms");
   }
}

Result
The above code sample will produce the following result. The result may vary.

Time taken for stringconcatenation using + operator : 0 ms
Time taken for String concatenationusing StringBuffer : 22 ms

-------------------------------------------------------------------------------------------------------------

How to do string concatenation ?

Following example shows concatenation string. This method returns a String with the value of the String passed into the method, appended to the end of the String, used to invoke this method.

public class HelloWorld {
   public static void main(String []args) {
      String s = "Hello";
      s = s.concat("word");
      System.out.print(s);
   }
}

Result
The above code sample will produce the following result. The result may vary.

Helloword