Program 1 (a,b)

Object 1a:
Write a program to display your name only.

Program:
10 CLS
20 PRINT "Saqiba Ehtesham"
30 END
RUN

Explaination:

  • CLS use to clear your monitor screen for your program output at line number 10.
  • PRINT use to display the name written in double qoutes. As the same name will appear on screen as many time you run this program because it is a constant value as name is not changing during execution of the program.
  • END us to inform the BASIC interpretor as the instructions are  finish.
  • RUN command use to inform BASIC interpretor to execute the instruction and display result.
Output:
Saqiba Ehtesham
____________________________________________________
Object 1b:
Write a program to display any name you enter.

Program:
10 CLS
20 INPUT " Enter name: " ; N$
30 PRINT " The name you enter : " ; N$
40 END
RUN

Explaination:

  • CLS use to clear your monitor screen for your program output at line number 10.
  • INPUT use to get some data from user of the program. It is a statement which need some action(data entry) during execution of the program. It must followed by a Variable ( name of a temporary location to store data during execution of the program). In this program variable N use with a $ sign which particulalry decalre it as a String variable. N$ holds data untill you exist the program. It also allow you to write a msg in double qoutation so user of program know what to do.
  • PRINT use to display the mesaage written in double qoutes. Followed by  the Variable N$ and display the value store in this variable. As the difderent  name will appear on screen as many time you run this program because it is a variable value as it will keep on changing during execution of the program.
  • END use to inform the BASIC interpretor as the instructions are  finish.
  • RUN command use to inform BASIC interpretor to execute the instruction and display result.
Output:
Enter name : saqiba ehtesham
Name you enter : saqiba ehtesham

No comments:

Post a Comment