Powered By Blogger

Friday, March 4, 2016

START PROGRAMING

                          let's start programing




  • First insert "program" then type name of your program and insert ';' mark(';' mark represent the ending of a line)
                               eg:  program add_num;

  • Then name Variables and Constants in your program.
                                eg: var num:integer;
                                      const pi=22/7;

  • Then type 'begin' to start the program. your program must be written between 'begin' and 'end'.
  • Try the following program.

 program num_add; 
var num1,num2,sum:integer; 
beginwrite('Enter your first number'); 
read(num1); 
write('Enter your second number'); 
read(num2); 
sum:=(num1+num2); 
writeln(sum); 
readln(sum); 
end.

  • In the above program you can see three variables.they are num1, num2, and sum.you have to add as integer after them because they are integers.
                            all integers                   :integer
                            decimal numbers         :real
                            English characters       :char
                            words/sentences          :string
  • The word 'write' is used to show it to the user. The word 'read' is used to understand the computer about the entered thing.
        eg: if you type write('my first program') the user of your program will see it as 'my first                             program'.
              according to the above program if you enter a number as your first number the                                     computer will read it as 'num1' .Therefor it must be a variable you introduced before.                           (if you enter a character program will not work)
  • Same thing happens in the second number too. The computer read the number you enter second as 'num2'.
  • Then computer add the numbers you entered. then a new variable is formed as 'sum'. finally user can see the 'sum' in the pascal window. 



3 comments: