Chapter 1 Notes Computers- machines that perform very simple tasks according to specific instructions Program- a set of instructions for a computer to follow Software- a collection of programs Hardware- the physical machines that make up a computer C
WELCOME TO CPSC 110
STRUCTURED PROGRAMMING IN
PASCAL
1
LECTURE INFORMATION
http:/people.cs.tamu.edu/yjoo9317/cpsc206/
2
INTRODUCTION TO COMPUTER SCIENCE
CONCEPTS AND PROGRAMMING
3
Outline
Part I: An overview of Computer Science. Part II: Compu
Chatper 9
Intro to Arrays
An array is a list of variables, each with a two-part name. one part is the same for each variable that make up the array. And the other is is different for each variable. Type smallarray = array [1.5] of integer; var score:
ORDINAL TYPES
A Type whose values are specified by a list is called an Ordinal Type.
Integer Char Boolean Given a value( e.g. `D' , 10 , False) in an ordinal type ,we can specify the one unique value which proceeds or follows the value.
Real and
{ -Program Description: This program will use procedures to evaluate the area of a triangle. pg.104 -} program TriangleArea(input,output); var a, b, c, s, area : real; {one side of the triangle} {one side of the triangle} {one side of the triangle} {
{ -Program Description: This program will use procedures to evaluate the hat, sweater, and pant sizes using the user's input of their weight, height, and age. pg.142 --} program Sizes; var height, weight, age, hatsize, sweatersize, pantsize : real; {
{ -Program Description: This program will use procedures to compare the prices of two different mechanics. It will accept the number of hours it will take to complete the job and then calculate the price of the services. pg.142 -} program Mechanics(i
{ -Program Description: This program will use procedures to evaluate gross and gross pay of the worker by inputing the number of hours worked and calculating withholdings. pg.104 --} program WorkersPay; const payrate= 9.63; sstax= 0.06; fitax= 0.14;
program Sizes; vars height, weight, age, hatsize, sweatersize, pantsize : real;
Procedure GetData(var height, weight, age: real); begin writeln('Please enter your height in inches, then press enter:'); readln(height); writeln('Please enter your weig
program Mechanics; vars hrs, quaterhrs, mechanic1charge, mechanic2charge : real;
Procedure GetData(var hrs:real); begin writeln('Please enter the number of hours you expect the job to take, then press return:'); readln(hrs); end; Procedure CalcQuart
{ -Program Description: This program will allow the user to compute their electric bill. pg.351 #22. -} program Grades; var Scores: array[1.50] of integer; Students: array[1.50] of integer;
{-PromptForInput: This procedure prompts the user to enter
{ -Program Description: This program will use procedures to evaluate gross and gross pay of the worker by inputing the number of hours worked and calculating withholdings. pg.104 --} program WorkersPay; const payrate= 9.63; sstax= 0.06; fitax= 0.14;
Chapter 7
Design And Implementation Of Loops
Repeat until : Repeat Body of Loop until Boolean Expression 1. Repeat Body Until Expression is True 2. No Compound statement used. 3. Always at least 1 pass through the loop.
116
Loop Categories
Conditi
Multi way Branching
If-Then Handles A 2-choice problem If Age > 65 Then else Code-1 Code - 2 ;
we either execute (1) Code-1 or (2) Code - 2
101
Problem: Assign the student the correct letter grade based on the following: 90 - 100 A 80 - 89 B 70 - 7
Chapter 5 Modularity, Functions, and Data Flow
Local Variables: The SCOPE of a valuable is determined by where the variable is created. A Local variable is one that is declared within a procedure. It is known and can be referenced ONLY within that pr
Predefined Functions
Name Type of Argument Type of Result Example
abs integer real real real integer real real or integer integer real integer integer integer real real abs (-2) abs (-2.4) round (2.6) trunc (2.6) sqr (2) sqr (1.100) sqrt (4)
Value o
CPSC 110 PASCAL PROGRAMMING
Developed at Dartmouth (1970) by Wirth Designed as a language that can be utilized to develop programs in a structured manner. A high-level general purpose language
1
General Format of a Pascal Program
Program Heading
Computer Science Notes
Chapter 4
Simple Pascal Procedures
Procedure declaration- name given to a sequence of statements. Procedure compliment; {heading} Begin { body} Writeln(`a lovely letter'); Writeln (`one of my favorites'); End; {end of body} In