The document describes the structure and syntax of the Pascal programming language. It outlines the typical components of a Pascal program which include the program name, library inclusions, constant and variable declarations, procedures, and main program body. It also provides examples of key words, variable types, assignment operations, and comments. The document concludes by providing a sample Pascal program that calculates income tax based on monthly salary input.
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
96 views
Pascal Structure - Syntax
The document describes the structure and syntax of the Pascal programming language. It outlines the typical components of a Pascal program which include the program name, library inclusions, constant and variable declarations, procedures, and main program body. It also provides examples of key words, variable types, assignment operations, and comments. The document concludes by providing a sample Pascal program that calculates income tax based on monthly salary input.
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 4
Pascal
Structure & Syntax
Structure (procedural) Program name Program Salary; Library inclusion Uses CRT; Constants declarations CONST (e.g. pi := 3.14;) (constants) Declaration of variables VAR (e.g. num1 : Real;) (variables)
Procedure declaration Procedure Menu;
(Reusable code) Begin (statements) End of program segment End; (not of program) Main body of program Begin (statements) Procedure call Menu; End of program End. Syntax ► Some reserved and key words: ► Variable types Program, Begin, End, Procedure, Write, Writeln, Read, Readln, Clrscr ► Most lines end with ; ► Assignment operator := (e.g. num1 := 45;) ► Define all declarations (and procedures) before main part of program ► Use same relational operators as algorithms ► Use single quotes for strings of text ► Comments inside curly braces {} Sample Income tax is calculated at 25% of annual salary in excess of $19,600. Write a Income tax is calculated at 25% of annual salary in excess of $19,600. Write a program to input the monthly salary then compute the annual salary and the amount of income tax due. Program Income; PRINT “INCOME TAX CALCULATOR” {uses crt;} PRINT “ENTER MONTHLY SALARY” INPUT MSAL VAR ASAL = MSAL * 12 TSAL = ASAL – 19600 msal, asal, tsal, tax : Real; TAX = TSAL * 0.25 PRINT “ANNUAL SALARY: “,ASAL Begin PRINT “INCOME TAX DUE: “,TAX Writeln('INCOME TAX CALCULATOR'); Write('ENTER MONHTLY SALARY: '); PRINT “INCOME TAX CALCULATOR” Readln(msal); PRINT “ENTER MONTHLY SALARY” INPUT MSAL# asal := msal *12; ASAL# = MSAL# * 12 tsal := asal - 19600; TSAL# = ASAL# – 19600 tax := tsal * 0.25; TAX# = TSAL# * 0.25 Writeln; PRINT “ANNUAL SALARY: “,ASAL# Writeln('ANNUAL SALARY: ',asal:5:2); PRINT “INCOME TAX DUE: “,TAX# Writeln('INCOME TAX DUE: ',tax:4:2); INPUT KEY End.
Building the Digital Enterprise A Guide to Constructing Monetization Models Using Digital Technologies Business in the Digital Economy Skilton Mark - Download the ebook and start exploring right away
Social Media Has Become a Huge Part of Our Lives. It Has Changed How We Communicate, How We Consume News, And How We Interact With Each Other. the Growth of Social Media Has Been Tremendous in the Past Decade. It Has