0% found this document useful (0 votes)
41 views

Algorithms 1 Beginning Concepts

This document provides an introduction to key concepts related to data and algorithms, including data processing, variables and constants, data types, functions, and operators. It discusses the different data types used in programming languages like C and Pascal, including integers, reals, characters, strings, logical values, and composite data types. It also defines functions as reusable blocks of code that perform specific tasks, and operators that are used to manipulate data in expressions and equations. The document concludes by noting there will be exercises to reinforce these foundational concepts.

Uploaded by

lordjebus2000
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Algorithms 1 Beginning Concepts

This document provides an introduction to key concepts related to data and algorithms, including data processing, variables and constants, data types, functions, and operators. It discusses the different data types used in programming languages like C and Pascal, including integers, reals, characters, strings, logical values, and composite data types. It also defines functions as reusable blocks of code that perform specific tasks, and operators that are used to manipulate data in expressions and equations. The document concludes by noting there will be exercises to reinforce these foundational concepts.

Uploaded by

lordjebus2000
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Beginning Concepts

relating to Data & Algorithms


Topics
• Data Processing
• Variables and Constants
• Data Types
• Functions
• Operators
– arithmetic
– relational
– logical
• Exercises
2
Data Processing

3
Variables and Constants
• Named memory locations where some value is stored.
– e.g. length, width, height
• value of a constant is initially set and cannot be varied.
– e.g. pi = 3.14159…
• value stored in a variable may be changed during
execution of the program.

4
Data Types
• integer
– in C, short int and long
– in Pascal integer,
• real or floating point
– in C, float and double
– in Pascal Float,
• character
– in C, char
– in Pascal, Char
• string, often treated as a list of characters
– in C, char[] or char *
5
Data Types
• logical
• in C, 0 represents false, true is any non zero number
• in Pascal, Bool has 2 values True and False
• composite data types, defined by programmer
• in C use struct
• in Pascal use record

6
Data Types

7
8
Functions
• functions, usually come with the language in a ‘library’
• a function usually performs a well defined specific task
– e.g. square root function
– sqrt 4.0 gives 2.0
• are used as parts of instructions in a program
• programmer uses them as part of his solution, leader to
shorter programs
• an application domain has its own functions

9
10
11
Operators

12
Operator Precedence or Hierarchy

13
Expressions and Equations

14
Example

15
Exercises

16
Exercises

17
Exercises

18

You might also like