CHAPTER-2 "Data Type Assinment & input/output Statement"

CHAPTER-2 “Data Type Assinment & input/output Statement”

Q NO: – What do you know about basic language? Write down its history and advantages.

Introduction to BASIC: – The word BASIC stands for Beginners All purpose Symbolic Instruction. BASIC language is one of the simplest high- level languages in use today. It is a general- purpose programming language. It is effective for many applications such as, business, science, games and education. Actually BASIC was designed for use in teaching the elementary principles of computer programming in a straightforward manner. That is why, it is particularly well suited for person learning to program for the first time. Because of its simplicity, it is now used almost universally. In Pakistan, many high and junior schools now offer courses in this programming language.

10th   5

HISTORY OF BASIC: – BASIC was developed by Dr.John G.Kemeny and Dr.Thomas E.Kurtz at Dartmouth Collage in the mid 1960s in an effort to provide a simple teaching language for beginners of computer programming. As BASIC was a simple and user-friendly language, so very quickly it became one of the most widely used languages in schools, and universities. It was also adopted as a principal language by several commercial timesharing services. All this made it a very popular language among thousands of computer users.

ADVANTAGE OF BASIC LANGUAGE: –There are the following advantages of the basic language.1. It has very simple and easy grammatical rules and therefore, easy for beginners to learn, and as such, can be learned in a very short period of time.2. BASIC is an All-purpose programming language. It is equally suitable for solving scientific and engineering problems as well as for business applications 3. BASIC has conversational nature, which makes communication with a computer simple, easy and almost natural. 4. BASIC is a user-friendly language. It is not a purely teaching language likes others and therefore, user fined it friendly. 5. Computer games can be developed in BASIC language requiring the use of graphics as well as sound generations. 6. One of the advantages of BASIC is its much built- in functions. 7. BASIC has the staying power to keep you hooked and busy until you have become an expert.
Q NO: – What do you meant by a program? Write down the structure of a BASIC program.

PROGRAM: – BASIC, lick other languages, has its own syntax or structure. Each instruction in a BASIC program is written as a separate statement that is called program.Structure of a BASIC program: – A complete BASIC program consists of a sequence of statements, which are executed in ascending order. General rules for writing a BASIC program are as follows.? Each statement must begin with an unsigned positive integer quantity known as a statement number (Line number).? Two statements cannot have the same statement or line number.? Successive statements must have increasing statement numbers.? Each statement number must be followed by a BASIC key word (like PRINT, READ, INPUT etc) indicating the type of instruction that is to be carried out.? Each statement begins with a statement number and ends with a Carriage Return (ENTER/RETURN/CR/). ? Each statement with an END statement, physically, it can by written any where in the program, but logically it must be the very last statement to be executed.

Q NO: – What for we use operator? What are its types? Explain each with suitable examples. Also explain priority of operators.

Operators are special characters used to perform specific operation on their operands (data type). In BASIC language we use three types of operators, which are listed below.

ARITHMETIC OPERATORS: -1. Following are the arithmetic operations.+ Use for addition- Use for subtraction * Use for multiplication/ Use for division\ Use for integer division MOD MOD used for remainder in division e.g 5 MOD 2 = 1^ Used for power or exponentiation() Used to change the default priorities of operators.

RELATIONAL OPERATORS:- 2. Following are the relational operators.< Used for less than> Used for greater than= Used for equal to<> Used for not equal to<= Used for less than or equal to>= Used for greater than or equal to

3. LOGICAL OPERATORS:-In BASIC we have three logical operators, which are AND, OR and NOT. AND and OR operators are used to form compound conditional expressions, in which more than one logical conditions are tested in the same statement.The NOT operator is used to negate an operand (i.e. change true to false and false to true)

CONSTANTS: – A constant in BASIC is something that does not change its value during execution of the program. There are two types of constants; Numeric constant and string constant. Numeric Constants: – Numeric constants are positive or negative number. A plus sign is optional for a positive number. A numeric constant in BASIC cannot contain commas. For example: 23, -4.756, + 38.15 String Constants:- A string constant is any set of characters enclosed in quotation marks. Blank spaces may be included in a string but not quotation marks. A string constant is a sepuence of 255 alphanumeric characters enclosed in double quotation marks. For example:- “AREA OF TRIANGLE” “** I LOVE PAKISTAN**” “23 RD MARCH” Variables: – Variables are the names or labels used to represent values that are used characters, the first character must be a letter like A, B, A1, A2 etc. However longer names may also be used. The number of character that can be used varies in different versions of BASIC. There are two types of variables. Numeric Variable: – A numeric variable always has a value that is a number. This value is assigned to the variable during the execution of a program. For example:- 10 Let A = 50 Prints A30 End String Variable: – A string is a sequence of characters that is letters, number, and certain special characters such as +, -, *, =, $, ?, etc. Blank spaces are also variables but the computer does not use them in calculations.A string variable must be written as a letter followed by a dollar sign for example A$, B$, NAME$ etc. as used in the following programmed. 1 Let A$ = “I”20 Let B$ = “LOVE”30 Let C$ = “PAKISTAN”40 Print A$, B$, C$ 50 End

Write short notes on the following?

1:- BASIC character set: – The BASIC character set consists of numeric character, alphabetic characters and special characters. The numeric characters are 0.1,2,3,4,5,6,7,8, and 9. The alphabetic characters are upper and lower- case letters of the English language.(A, B, C, D …Z ANSD a, b, c, d…z). The special character are the Period (.), Comma (,), Semicolon (;) etc. 2:- Reserved Words: – Reserved words are those words which are reserved in the language for the specific purpose and can not be used for any other purpose. These have special meaning and computer knows their meanings. Some of the most frequently used BASIC Reserved words are given below.ABC AND ASC ATN AUTO BEEP CHRS CINT CIRLCE CLOSE COS DATA DATES DEF DELETE END DIM ELSE FILES FIX FN FOR GOSUB GOTO IF INKEY$ INPUT KILL LIST LOAD NEW MOD NEXT PRINT READ REM RETURN RUN SAVE SQR STEP STOP SWAP SYSTEM THEN TO WRITE etc. Modes of Operations:- In BAISC there are two types of Modes are used:- Direct Mode:- The direct Mode instruction are executed directly, to perform the desired task, as and when entered without the need for using RUN command. After each direct command the screen display “OK” prompt. Indirect Mode: – Each statement begins with a statement number; we call it Indirect Mode of operation. In this case all the statement is stored in the memory and is executed only when RUN command is display.

Difference between:-?

Constant and Variable: – Constant is a value that can not be changed, while variable, unlike constant, change their value during the execution of program? Numeric variable and String variable: – A numeric variable is used to hold only numeric constants. For example: – A, XYZ, Ali etc. A string variable is used to hold characters. These characters may be alphabets, number, or special symbols. For example NAME$, ADDRESS$, A1$.? Commands and statements:- Commands is the name of action while a statement ask computer to do some work. Each statement can be consists of one or more lines? Input statement and Red and Data statement:- Input statement is used to accept input data from keyboard and assigns this to a variable. This input data may be a numeric value or character string. Syntax: – [line no] Input {“prompt”} [variable] {‘variable’}….Example: – 15 INPUT A$, PH_NO Read and data statement: – READ statement is used to assign numeric values or character strings to variables. These numeric values or character strings are provided by DATA statement. For each variable of READ statement there should be one value of same type in DATA statement.Syntax: – [line no] READ [variable] {‘arable’}…. [Line no] READ [variable] {‘arable’}…Example:- 30 READ CITY$40 DATA “KAMOKE”

String Variable: – A string is a sequence of characters that is letters, number, and certain special characters such as +, -, *, =, $, ?, etc. Blank spaces are also variables but the computer does not use them in calculations. A string variable must be written as a letter followed by a dollar sign for example A$, B$, NAME$ etc. as used in the following programmed. 1 Let A$ = “I” 20 Let B$ = “LOVE” 30 Let C$ = “PAKISTAN” 40 Print A$, B$, C$ 50 End

]]>

admin

Leave a Reply

Your email address will not be published. Required fields are marked *