This lab aims to develop the student knowledge and skills data types, required memory storage for each data type, selection of appropriate data types, naming variables, This lab aims to develop the student knowledge, and skills in identifying the appropriate data-types for variables, calculate the required memory storage for each data type, naming variables, casting of data types, and mathematic operations, the casting of data types, and arithmetic operations.
The document discusses Python's four main collection data types: lists, tuples, sets, and dictionaries. It provides details on lists, including that they are ordered and changeable collections that allow duplicate members. Lists can be indexed, sliced, modified using methods like append() and insert(), and have various built-in functions that can be used on them. Examples are provided to demonstrate list indexing, slicing, changing elements, adding elements, removing elements, and built-in list methods.
The document discusses heap memory management. It describes the heap as the portion of memory used for indefinitely stored data. A memory manager subsystem allocates and deallocates space in the heap. It keeps track of free space and serves as the interface between programs and the operating system. When allocating memory, the manager either uses available contiguous space or increases heap size from the OS. Deallocated space is returned to the free pool but memory is not returned to the OS when heap usage drops.
basic of desicion control statement in pythonnitamhaske
it consists if-else, nested if, if-elif-else, for loop, while loop with flowchart and examples. also continue ,pass and break statement.
and else with for and while loop
This document discusses operator precedence parsing and describes the third and fourth steps:
- Parsing the input string based on a precedence relation table by shifting and reducing tokens.
- Constructing a parse tree from the parse table by focusing on reduce actions and building the tree from the bottom up.
Two examples are provided to demonstrate how operator precedence parsing can determine if an input string is valid based on a given grammar. Parse tables and trees are constructed to show the parsing process.
The document describes a simple code generator that generates target code for a sequence of three-address statements. It tracks register availability using register descriptors and variable locations using address descriptors. For each statement, it determines the locations of operands, copies them to a register if needed, performs the operation, updates the register and address descriptors, and stores values before procedure calls or basic block boundaries. It uses a getreg function to determine register allocation. Conditional statements are handled using compare and jump instructions and condition codes.
The document discusses basic blocks and flow graphs in program representation. It defines basic blocks as straight-line code segments with a single entry and exit point. To construct the representation:
1. The program is partitioned into basic blocks
2. A flow graph is created where basic blocks are nodes and edges show control flow between blocks
The flow graph explicitly represents all execution paths between basic blocks. Loops in the flow graph are identified by having a single loop entry node with all paths from the start going through it, and all nodes inside the loop reaching the entry.
The document discusses Python's four main collection data types: lists, tuples, sets, and dictionaries. It provides details on lists, including that they are ordered and changeable collections that allow duplicate members. Lists can be indexed, sliced, modified using methods like append() and insert(), and have various built-in functions that can be used on them. Examples are provided to demonstrate list indexing, slicing, changing elements, adding elements, removing elements, and built-in list methods.
The document discusses heap memory management. It describes the heap as the portion of memory used for indefinitely stored data. A memory manager subsystem allocates and deallocates space in the heap. It keeps track of free space and serves as the interface between programs and the operating system. When allocating memory, the manager either uses available contiguous space or increases heap size from the OS. Deallocated space is returned to the free pool but memory is not returned to the OS when heap usage drops.
basic of desicion control statement in pythonnitamhaske
it consists if-else, nested if, if-elif-else, for loop, while loop with flowchart and examples. also continue ,pass and break statement.
and else with for and while loop
This document discusses operator precedence parsing and describes the third and fourth steps:
- Parsing the input string based on a precedence relation table by shifting and reducing tokens.
- Constructing a parse tree from the parse table by focusing on reduce actions and building the tree from the bottom up.
Two examples are provided to demonstrate how operator precedence parsing can determine if an input string is valid based on a given grammar. Parse tables and trees are constructed to show the parsing process.
The document describes a simple code generator that generates target code for a sequence of three-address statements. It tracks register availability using register descriptors and variable locations using address descriptors. For each statement, it determines the locations of operands, copies them to a register if needed, performs the operation, updates the register and address descriptors, and stores values before procedure calls or basic block boundaries. It uses a getreg function to determine register allocation. Conditional statements are handled using compare and jump instructions and condition codes.
The document discusses basic blocks and flow graphs in program representation. It defines basic blocks as straight-line code segments with a single entry and exit point. To construct the representation:
1. The program is partitioned into basic blocks
2. A flow graph is created where basic blocks are nodes and edges show control flow between blocks
The flow graph explicitly represents all execution paths between basic blocks. Loops in the flow graph are identified by having a single loop entry node with all paths from the start going through it, and all nodes inside the loop reaching the entry.
This document discusses parsing and context-free grammars. It defines parsing as verifying that tokens generated by a lexical analyzer follow syntactic rules of a language using a parser. Context-free grammars are defined using terminals, non-terminals, productions and a start symbol. Top-down and bottom-up parsing are introduced. Techniques for grammar analysis and improvement like left factoring, eliminating left recursion, calculating first and follow sets are explained with examples.
Clock synchronization in distributed systemSunita Sahu
This document discusses several techniques for clock synchronization in distributed systems:
1. Time stamping events and messages with logical clocks to determine partial ordering without a global clock. Logical clocks assign monotonically increasing sequence numbers.
2. Clock synchronization algorithms like NTP that regularly adjust system clocks across the network to synchronize with a time server. NTP uses averaging to account for network delays.
3. Lamport's logical clocks algorithm that defines "happened before" relations and increments clocks between events to synchronize logical clocks across processes.
The document discusses various concurrency control techniques for databases including locking-based approaches like two-phase locking and multi-version concurrency control. It also covers non-locking approaches like timestamp ordering and validation (optimistic) concurrency control. Multiple granularity locking is described as a way to control concurrent access at different levels of data abstraction.
This document discusses Bayesian learning and the Bayes theorem. Some key points:
- Bayesian learning uses probabilities to calculate the likelihood of hypotheses given observed data and prior probabilities. The naive Bayes classifier is an example.
- The Bayes theorem provides a way to calculate the posterior probability of a hypothesis given observed training data by considering the prior probability and likelihood of the data under the hypothesis.
- Bayesian methods can incorporate prior knowledge and probabilistic predictions, and classify new instances by combining predictions from multiple hypotheses weighted by their probabilities.
This document discusses different techniques for reading files in Python. It begins by explaining what files are and the different types, with a focus on text files. It then demonstrates opening a file and reading the entire contents in one string. Next, it shows how to read each line of a file as a separate string using readlines(). Finally, it provides an example of printing the lines of a file in reverse order to illustrate reading files in different ways. The key techniques covered are reading the entire file, reading a specified number of characters, reading each line as a separate string, and iterating through the lines in reverse order.
The document discusses logic programming and propositional logic. It covers topics like:
- Logic is the study of valid reasoning and determining what conclusions follow from a set of premises.
- Propositional logic represents logical statements using variables and logical connectives. It deals with propositions that can be either true or false.
- Predicate logic extends propositional logic by allowing reasoning about objects and relationships using variables, predicates, functions and quantifiers.
- Logic programming languages like Prolog are based on predicate logic and allow defining facts and rules to represent relationships between objects. Prolog can be used to infer new facts by applying resolution and unification on queries against the defined facts and rules.
This document discusses passing values and references between functions. It explains that passing by value creates a copy of the value, while passing by reference passes a pointer to the object without copying data. Passing by value is better for multi-threaded applications and distributed systems as it simplifies memory management, while passing by reference can reduce memory overhead but requires memory management and can cause issues with multithreading. It also defines which types are considered value types and reference types in different languages like Java, Objective-C and Swift.
This document provides an overview of timestamp protocols in database management systems. It discusses how timestamps are generated and used to order transactions. The basic timestamp ordering protocol checks timestamps on read and write operations to ensure serializability. Strict timestamp ordering delays some transactions to ensure schedules are both serializable and strict. Multiversion timestamp ordering uses multiple versions of data items to allow reads to always succeed while maintaining serializability.
This document summarizes key concepts from Chapter 5 of the textbook "Operating System Concepts - 8th Edition" regarding CPU scheduling. It introduces CPU scheduling as the basis for multiprogrammed operating systems. Various scheduling algorithms are described such as first-come first-served, shortest job first, priority scheduling, and round robin. Criteria for evaluating scheduling algorithms include CPU utilization, throughput, turnaround time, waiting time, and response time. Ready queues can be partitioned into multiple levels with different scheduling policies to implement multilevel queue and feedback queue scheduling.
This slide is used to do an introduction for the matplotlib library and this will be a very basic introduction. As matplotlib is a very used and famous library for machine learning this will be very helpful to teach a student with no coding background and they can start the plotting of maps from the ending of the slide by there own.
The document describes external sorting techniques used when data is too large to fit in main memory. It discusses two-way sorting which uses two tape drive pairs to alternately write sorted runs. It also covers multi-way merging which merges multiple runs simultaneously using a heap. The techniques can improve performance over standard internal sorting.
Performance analysis(Time & Space Complexity)swapnac12
The document discusses algorithms analysis and design. It covers time complexity and space complexity analysis using approaches like counting the number of basic operations like assignments, comparisons etc. and analyzing how they vary with the size of the input. Common complexities like constant, linear, quadratic and cubic are explained with examples. Frequency count method is presented to determine tight bounds of time and space complexity of algorithms.
Virtual memory management techniques allow processes to access memory in a virtual address space that is larger than the actual physical memory. There are three main techniques:
1. Demand paging only loads pages into memory when they are needed, reducing I/O and memory usage but increasing access time due to page faults.
2. Copy-on-write shares pages between processes until a page is modified, then it is copied to avoid overwriting another process's page.
3. Page replacement algorithms select victim pages to remove from memory and write to disk when new pages are needed. Least recently used is commonly used but not optimal.
The document discusses sequential covering algorithms for learning rule sets from data. It describes how sequential covering algorithms work by iteratively learning one rule at a time to cover examples, removing covered examples, and repeating until all examples are covered. It also discusses variations of this approach, including using a general-to-specific beam search to learn each rule and alternatives like the AQ algorithm that learn rules to cover specific target values. Finally, it describes how first-order logic can be used to learn more general rules than propositional logic by representing relationships between attributes.
This document summarizes key topics in intermediate code generation discussed in Chapter 6, including:
1) Variants of syntax trees like DAGs are introduced to share common subexpressions. Three-address code is also discussed where each instruction has at most three operands.
2) Type checking and type expressions are covered, along with translating expressions and statements to three-address code. Control flow statements like if/else are also translated using techniques like backpatching.
3) Backpatching allows symbolic labels in conditional jumps to be resolved by a later pass that inserts actual addresses, avoiding an extra pass. This and other control flow translation topics are covered.
This document discusses Bayesian networks and uncertainty in artificial intelligence. It provides an introduction to Bayesian networks, including how they can be used to represent probabilistic relationships between variables. Judea Pearl received the 2011 ACM Turing Award for his fundamental contributions to artificial intelligence through the development of Bayesian networks and a calculus for probabilistic reasoning. The document outlines the contents to be covered, which include motivational examples of Bayesian networks, decomposing joint distributions, inference in Bayesian networks, and their advantages as AI tools.
This document discusses segmentation in operating systems. Segmentation divides memory into variable-sized segments rather than fixed pages. Each process is divided into segments like the main program, functions, variables, etc. There are two types of segmentation: virtual memory segmentation which loads segments non-contiguously and simple segmentation which loads all segments together at once but non-contiguously in memory. Segmentation uses a segment table to map the two-part logical address to the single physical address through looking up the segment base address.
This document discusses weak slot-and-filler knowledge representation structures. It describes how slots represent attributes and fillers represent values. Semantic networks are provided as an example where nodes represent objects/values and links represent relationships. Property inheritance allows subclasses to inherit attributes from more general superclasses. Frames are also discussed as a type of weak structure where each frame contains slots and associated values describing an entity. The document notes challenges with tangled hierarchies and provides examples of how to resolve conflicts through inferential distance in the property inheritance algorithm.
Data Type is a basic classification which identifies.docxtheodorelove43763
Data Type is a basic classification which identifies different types of data.Data Types helps in:Determining the possible values of a variablePossible operations which can be executed on the typeMeaning of the dataDifferent ways to store the data
Data Types are of different types:
Primitive data Types
Composite Data Types
*
Primitive data types are those data types which are not defined in terms of other data types.
Examples are:
Integer
Floating Point
Boolean
Character
*
NOTE: primitive here is not the same as how we use it when referring to the primitive types in Java even though they are mostly the same types. By primitive, we mean directly supported by hardware. Strings do not appear in this list because strings are rarely supported directly in hardware, instead they are stored as individual characters and linked together through some mechanism implemented by the programming language (usually as arrays of characters).
What about pointer types? You’ll notice that they do not appear above. Typically, pointers are just unsigned int values. But we treat pointers differently than ints because we do not permit pointer arithmetic (except in a few languages) and require dereferencing of some kind. Dereferencing may be directly supported in hardware by having indirect addressing modes.
Integers are used to hold integer values only.This is further categorized into:
byte
short
int
long
signed
Unsigned
Examples are:
unsigned int x = 21234;
unsigned int y = 31234;
unsigned int z;
z = x + y;
This data type contains decimal points.Examples are:
float f = 20.0 / 3.0;
Current standard version of floating-point
Single-precision (float)
One word: 1 sign bit, 23 bit fraction, 8 bit exponent
Positive range: 1.17549435 × 10-38 … 3.40282347 × 10+38
Double-precision (double)
Two words: 1 sign bit, 52 bit fraction, 11 bit exponent
Positive range: 2.2250738585072014 × 10-308 … 1.7976931348623157 × 10+308
*
Boolean Data type is used to store logical value.It can have either True or False value.It is a one bit representation0 represents false value1 represents true valueExample: Boolean a;
a=true;
Roman alphabet, punctuation, digits, and other symbols:Can encode within one byte (256 symbols)
In C:
char a_char = ’a’;
char newline_char = ’\n’;
char tab_char = ’\t’;
char backslash_char = ’\\’;
These data types are derived from more than one primitive data type.Examples are:
Arrays
Records
Structure
Union
Arrays are a finite sequence of variables of the same data type These are commonly implemented by the compiler generating array descriptors for each array
here we have
descriptors for
1-D and multi-D
arrays
*
Records are Varied aggregate of data elementsThe elements of a record are known as fields or membersRecords were introduced in COBOLThis data type is used in many languages.In Java, the functionality of records are achieved through the use of classes
Examples:
COBOL (nested structure.
The document discusses the eight primitive data types in Java - boolean, char, byte, short, int, long, float, and double. It explains what each type is used for, their possible value ranges, and when to use each type. Key points covered include int being the preferred integer type, double the preferred real number type, and the importance of declaring variables before use and giving them initial values.
This document discusses parsing and context-free grammars. It defines parsing as verifying that tokens generated by a lexical analyzer follow syntactic rules of a language using a parser. Context-free grammars are defined using terminals, non-terminals, productions and a start symbol. Top-down and bottom-up parsing are introduced. Techniques for grammar analysis and improvement like left factoring, eliminating left recursion, calculating first and follow sets are explained with examples.
Clock synchronization in distributed systemSunita Sahu
This document discusses several techniques for clock synchronization in distributed systems:
1. Time stamping events and messages with logical clocks to determine partial ordering without a global clock. Logical clocks assign monotonically increasing sequence numbers.
2. Clock synchronization algorithms like NTP that regularly adjust system clocks across the network to synchronize with a time server. NTP uses averaging to account for network delays.
3. Lamport's logical clocks algorithm that defines "happened before" relations and increments clocks between events to synchronize logical clocks across processes.
The document discusses various concurrency control techniques for databases including locking-based approaches like two-phase locking and multi-version concurrency control. It also covers non-locking approaches like timestamp ordering and validation (optimistic) concurrency control. Multiple granularity locking is described as a way to control concurrent access at different levels of data abstraction.
This document discusses Bayesian learning and the Bayes theorem. Some key points:
- Bayesian learning uses probabilities to calculate the likelihood of hypotheses given observed data and prior probabilities. The naive Bayes classifier is an example.
- The Bayes theorem provides a way to calculate the posterior probability of a hypothesis given observed training data by considering the prior probability and likelihood of the data under the hypothesis.
- Bayesian methods can incorporate prior knowledge and probabilistic predictions, and classify new instances by combining predictions from multiple hypotheses weighted by their probabilities.
This document discusses different techniques for reading files in Python. It begins by explaining what files are and the different types, with a focus on text files. It then demonstrates opening a file and reading the entire contents in one string. Next, it shows how to read each line of a file as a separate string using readlines(). Finally, it provides an example of printing the lines of a file in reverse order to illustrate reading files in different ways. The key techniques covered are reading the entire file, reading a specified number of characters, reading each line as a separate string, and iterating through the lines in reverse order.
The document discusses logic programming and propositional logic. It covers topics like:
- Logic is the study of valid reasoning and determining what conclusions follow from a set of premises.
- Propositional logic represents logical statements using variables and logical connectives. It deals with propositions that can be either true or false.
- Predicate logic extends propositional logic by allowing reasoning about objects and relationships using variables, predicates, functions and quantifiers.
- Logic programming languages like Prolog are based on predicate logic and allow defining facts and rules to represent relationships between objects. Prolog can be used to infer new facts by applying resolution and unification on queries against the defined facts and rules.
This document discusses passing values and references between functions. It explains that passing by value creates a copy of the value, while passing by reference passes a pointer to the object without copying data. Passing by value is better for multi-threaded applications and distributed systems as it simplifies memory management, while passing by reference can reduce memory overhead but requires memory management and can cause issues with multithreading. It also defines which types are considered value types and reference types in different languages like Java, Objective-C and Swift.
This document provides an overview of timestamp protocols in database management systems. It discusses how timestamps are generated and used to order transactions. The basic timestamp ordering protocol checks timestamps on read and write operations to ensure serializability. Strict timestamp ordering delays some transactions to ensure schedules are both serializable and strict. Multiversion timestamp ordering uses multiple versions of data items to allow reads to always succeed while maintaining serializability.
This document summarizes key concepts from Chapter 5 of the textbook "Operating System Concepts - 8th Edition" regarding CPU scheduling. It introduces CPU scheduling as the basis for multiprogrammed operating systems. Various scheduling algorithms are described such as first-come first-served, shortest job first, priority scheduling, and round robin. Criteria for evaluating scheduling algorithms include CPU utilization, throughput, turnaround time, waiting time, and response time. Ready queues can be partitioned into multiple levels with different scheduling policies to implement multilevel queue and feedback queue scheduling.
This slide is used to do an introduction for the matplotlib library and this will be a very basic introduction. As matplotlib is a very used and famous library for machine learning this will be very helpful to teach a student with no coding background and they can start the plotting of maps from the ending of the slide by there own.
The document describes external sorting techniques used when data is too large to fit in main memory. It discusses two-way sorting which uses two tape drive pairs to alternately write sorted runs. It also covers multi-way merging which merges multiple runs simultaneously using a heap. The techniques can improve performance over standard internal sorting.
Performance analysis(Time & Space Complexity)swapnac12
The document discusses algorithms analysis and design. It covers time complexity and space complexity analysis using approaches like counting the number of basic operations like assignments, comparisons etc. and analyzing how they vary with the size of the input. Common complexities like constant, linear, quadratic and cubic are explained with examples. Frequency count method is presented to determine tight bounds of time and space complexity of algorithms.
Virtual memory management techniques allow processes to access memory in a virtual address space that is larger than the actual physical memory. There are three main techniques:
1. Demand paging only loads pages into memory when they are needed, reducing I/O and memory usage but increasing access time due to page faults.
2. Copy-on-write shares pages between processes until a page is modified, then it is copied to avoid overwriting another process's page.
3. Page replacement algorithms select victim pages to remove from memory and write to disk when new pages are needed. Least recently used is commonly used but not optimal.
The document discusses sequential covering algorithms for learning rule sets from data. It describes how sequential covering algorithms work by iteratively learning one rule at a time to cover examples, removing covered examples, and repeating until all examples are covered. It also discusses variations of this approach, including using a general-to-specific beam search to learn each rule and alternatives like the AQ algorithm that learn rules to cover specific target values. Finally, it describes how first-order logic can be used to learn more general rules than propositional logic by representing relationships between attributes.
This document summarizes key topics in intermediate code generation discussed in Chapter 6, including:
1) Variants of syntax trees like DAGs are introduced to share common subexpressions. Three-address code is also discussed where each instruction has at most three operands.
2) Type checking and type expressions are covered, along with translating expressions and statements to three-address code. Control flow statements like if/else are also translated using techniques like backpatching.
3) Backpatching allows symbolic labels in conditional jumps to be resolved by a later pass that inserts actual addresses, avoiding an extra pass. This and other control flow translation topics are covered.
This document discusses Bayesian networks and uncertainty in artificial intelligence. It provides an introduction to Bayesian networks, including how they can be used to represent probabilistic relationships between variables. Judea Pearl received the 2011 ACM Turing Award for his fundamental contributions to artificial intelligence through the development of Bayesian networks and a calculus for probabilistic reasoning. The document outlines the contents to be covered, which include motivational examples of Bayesian networks, decomposing joint distributions, inference in Bayesian networks, and their advantages as AI tools.
This document discusses segmentation in operating systems. Segmentation divides memory into variable-sized segments rather than fixed pages. Each process is divided into segments like the main program, functions, variables, etc. There are two types of segmentation: virtual memory segmentation which loads segments non-contiguously and simple segmentation which loads all segments together at once but non-contiguously in memory. Segmentation uses a segment table to map the two-part logical address to the single physical address through looking up the segment base address.
This document discusses weak slot-and-filler knowledge representation structures. It describes how slots represent attributes and fillers represent values. Semantic networks are provided as an example where nodes represent objects/values and links represent relationships. Property inheritance allows subclasses to inherit attributes from more general superclasses. Frames are also discussed as a type of weak structure where each frame contains slots and associated values describing an entity. The document notes challenges with tangled hierarchies and provides examples of how to resolve conflicts through inferential distance in the property inheritance algorithm.
Data Type is a basic classification which identifies.docxtheodorelove43763
Data Type is a basic classification which identifies different types of data.Data Types helps in:Determining the possible values of a variablePossible operations which can be executed on the typeMeaning of the dataDifferent ways to store the data
Data Types are of different types:
Primitive data Types
Composite Data Types
*
Primitive data types are those data types which are not defined in terms of other data types.
Examples are:
Integer
Floating Point
Boolean
Character
*
NOTE: primitive here is not the same as how we use it when referring to the primitive types in Java even though they are mostly the same types. By primitive, we mean directly supported by hardware. Strings do not appear in this list because strings are rarely supported directly in hardware, instead they are stored as individual characters and linked together through some mechanism implemented by the programming language (usually as arrays of characters).
What about pointer types? You’ll notice that they do not appear above. Typically, pointers are just unsigned int values. But we treat pointers differently than ints because we do not permit pointer arithmetic (except in a few languages) and require dereferencing of some kind. Dereferencing may be directly supported in hardware by having indirect addressing modes.
Integers are used to hold integer values only.This is further categorized into:
byte
short
int
long
signed
Unsigned
Examples are:
unsigned int x = 21234;
unsigned int y = 31234;
unsigned int z;
z = x + y;
This data type contains decimal points.Examples are:
float f = 20.0 / 3.0;
Current standard version of floating-point
Single-precision (float)
One word: 1 sign bit, 23 bit fraction, 8 bit exponent
Positive range: 1.17549435 × 10-38 … 3.40282347 × 10+38
Double-precision (double)
Two words: 1 sign bit, 52 bit fraction, 11 bit exponent
Positive range: 2.2250738585072014 × 10-308 … 1.7976931348623157 × 10+308
*
Boolean Data type is used to store logical value.It can have either True or False value.It is a one bit representation0 represents false value1 represents true valueExample: Boolean a;
a=true;
Roman alphabet, punctuation, digits, and other symbols:Can encode within one byte (256 symbols)
In C:
char a_char = ’a’;
char newline_char = ’\n’;
char tab_char = ’\t’;
char backslash_char = ’\\’;
These data types are derived from more than one primitive data type.Examples are:
Arrays
Records
Structure
Union
Arrays are a finite sequence of variables of the same data type These are commonly implemented by the compiler generating array descriptors for each array
here we have
descriptors for
1-D and multi-D
arrays
*
Records are Varied aggregate of data elementsThe elements of a record are known as fields or membersRecords were introduced in COBOLThis data type is used in many languages.In Java, the functionality of records are achieved through the use of classes
Examples:
COBOL (nested structure.
The document discusses the eight primitive data types in Java - boolean, char, byte, short, int, long, float, and double. It explains what each type is used for, their possible value ranges, and when to use each type. Key points covered include int being the preferred integer type, double the preferred real number type, and the importance of declaring variables before use and giving them initial values.
its all about java variable.....you may also learn about various data type by this slide. freshers become helpful to read out this.this slides also may helpful in your varsity java course class .in this slide there is vast discussion about java variable
Data types define the type of data that variables can store in a C program. There are three main types of data types: primitive, derived, and user-defined. Primitive types include integer, character, float, and double, which store numeric or character values of different ranges and sizes. Derived types are based on primitive types, while user-defined types like enums allow the user to define their own custom data types as a series of integer constants.
Java is a popular programming language created in 1995 that is used for mobile apps, desktop apps, web apps, servers, and more. It works across different platforms and is easy to learn and use. The document provides examples of how to write a simple "Hello World" Java program and how to declare and use variables of different data types like String, int, float, and boolean. It also covers Java operators.
Here are three classes that meet the requirements outlined in the homework:
1. Employee class with get/set methods for name, salary, and method to calculate yearly salary with a raise.
2. Invoice class with get/set methods for part number, description, quantity, price, and method to calculate invoice amount.
3. Date class with get/set methods for month, day, year, and method to display date in MM/DD/YYYY format.
variablesfinal-170820055428 data type resultsatifmugheesv
This document introduces variables, data types, and constants in C++. It defines a variable as a memory location used to store values. Variables are declared using a data type and identifier. Data types define a set of values and operations, and include basic types like int, char, float, and void. The document discusses the size, range, and examples of values for each data type. It also covers declaring and initializing variables as well as declaring constants in C++.
The document discusses various data types in C++. It explains that data types define the type of data stored in variables and associated operations. There are fundamental data types like integer, character, float, double, and void provided by C++. User-defined data types include arrays, pointers, references, structures, unions, classes and enumerations. The document provides details on the size and range of standard data types like short int, int, long, float, double etc. It also explains various type modifiers and derived data types.
This document provides a summary of 16 lessons on C programming:
1. The first few lessons cover include files, the main function, and system pause for prompting user input.
2. Later lessons cover printing messages, commenting code, declaring and assigning variables, and variable types.
3. The final lessons demonstrate mathematical operations in C using addition, subtraction, multiplication, division, and modulos and operating on multiple variables.
This document discusses revisiting SQL basics and advanced topics. It covers objectives, assumptions, and topics to be covered including staying clean with conventions, data types, revisiting basics, joining, subqueries, joins versus subqueries, group by, set operations, and case statements. The topics sections provides details on each topic with examples to enhance SQL knowledge and write better queries.
The document describes the order of presentation for a group project. Etukudo Andy will introduce the project and order of presentation. Adewumi Ezekiel will present on the numerical data project and contribution. Fajuko Micheal will run the program and discuss contribution. Finally, Afia Kennedy will provide the conclusion and link the project to previous lectures, discussing contribution.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
Database management systems (DBMS) allow users to create and maintain databases. A database is a collection of organized information that can be easily accessed, managed, and updated. Relational database management systems (RDBMS) use tables to maintain data records and indices. The ACID properties ensure transaction integrity during database modifications. Normalization organizes data to minimize redundancy by dividing tables and defining relationships between them. Denormalization adds redundant data to improve read performance in read-intensive applications. Tables contain data organized into vertical columns and horizontal rows. Data types specify the type of data in columns. Primary keys uniquely identify each record while foreign keys reference other tables' primary keys to link data and maintain referential integrity.
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Examshishamrizvi
The document provides an overview of key concepts in C++ including:
- Data types like int, char, float, and double
- Variables, constants, and escape sequences
- Operators like assignment, arithmetic, relational, and logical operators
- Control structures like if/else, switch, for, while, and do-while loops
- Functions like main(), exit(), get(), put(), and getline()
- Input/output streams like cin, cout, and file streams
The document covers fundamental C++ concepts to help prepare for board exams.
COMPLEX AND USER DEFINED TYPESPlease note that the material on t.docxdonnajames55
COMPLEX AND USER DEFINED TYPES
Please note that the material on this website is not intended to be exhaustive.
This is intended as a summary and supplementary material to required textbook.
INTRODUCTION
Previously we have been dealing with C++ built-in types, that is: types that the language already supports. In addition, all of the types we have been using so far (with two exceptions: string, and the reference type: &) have been simple types. In this module we will begin to look at complex types, sometimes called structured types. Complex types allow the programmer to define their own types, which we will call user defined types.
C++ Built-In Types
Classification
Name
Examples
Can be unsigned?
Simple
Integral
char
yes
"
"
short
yes
"
"
int
yes
"
"
long
yes
"
"
bool
no
"
Enumerated
enum
"
"
Decimal
float
"
"
"
double
"
"
"
long double
"
Address
Pointer
* (asterisk)
"
"
Reference
& (ampersand)
"
Complex
Array
[ ] (brackets)
"
"
Structured
struct
"
"
Union
union
"
"
Abstract
class
"
In this module we will explain enumerations, structures, and unions. In future modules we will cover arrays and classes.
Some classifications above may come as a surprise. How can char be an integral type (and even unsigned), and why is bool considered an integral type?
Characters in C++ are considered 8-bit bytes, and hence they are represented internally as integers in base 2: just 0s and 1s. If you want an integer that only ranges between 0 and 255 (unsigned), or between -128 and 127 (signed), you can use a char. All of the arithmetic operations can be used on char.
A character (char) was originally taken to be one of the symbols on your keyboard, and to represent those only need 7 bits are needed. Extended character sets must use 2 or more bytes to represent characters not on your keyboard (such a representation scheme is known as Unicode), for instance, Cyrillic characters or some mathematic symbols.
We have already seen that the Boolean true and false are really internally represented as 1 and 0, respectively. However, arithmetic operations will not work on bool.
You will also notice that a type we have used repeatedly (string) is not listed above. The strings we have been using are really of type class, which will be introduced another module.
ENUMERATIONS
Enumerated types are user-defined; that is, you get to choose what you want to enumerate. Here are some simple examples:
enum PrimaryColors {RED, YELLOW, BLUE}; enum Days {SUN, MON, YUE, WED, THU, FRI, SAT};
C++ will internally represent these types using 0, 1, 2, 3, .... Notice that the standard convention is to use upper-case alphas in the enumeration, as they are really very similar to constants. You can override the internal defaults with something like the following:
enum PrimaryColors {RED = 5, YELLOW = 10, BLUE = 20};
The default internal representation is often very convenient, as the enumeration symbol strings can then be used as indices of arrays, a future topic.
STRUCT.
Similar to CIS 1403 Lab 2- Data Types and Variables (20)
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Zilliz
Join us to introduce Milvus Lite, a vector database that can run on notebooks and laptops, share the same API with Milvus, and integrate with every popular GenAI framework. This webinar is perfect for developers seeking easy-to-use, well-integrated vector databases for their GenAI apps.
“An Outlook of the Ongoing and Future Relationship between Blockchain Technologies and Process-aware Information Systems.” Invited talk at the joint workshop on Blockchain for Information Systems (BC4IS) and Blockchain for Trusted Data Sharing (B4TDS), co-located with with the 36th International Conference on Advanced Information Systems Engineering (CAiSE), 3 June 2024, Limassol, Cyprus.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
1. Lab 2: Data Types and Variables
CIS 1403
Fundamentals of
Programming
201810
2. Introduction
This lab aims to develop the student knowledge and skills data types, required
memory storage for each data type, selection of appropriate data types, naming
variables, This lab aims to develop the student knowledge, and skills in identifying
the appropriate data-types for variables, calculate the required memory storage
for each data type, naming variables, casting of data types, and mathematic
operations. casting of data types, and athematic operations.
Skill-set
By completing this lab, the students will develop the following skills:
• Using appropriate and efficient data types to store data.
• Calculate the memory storage required for each data type
• Convert from binary to decimal systems
• Create variables that follow the rules of naming variables
• Apply correct athematic operators with the correct precedence
of operators
• Apply data type casting that does result in loss of data
How to use this lab?
Follow the lab instruction in step by step and complete all exercises. Watch
the associated videos.
Modify the examples to and exercises to experiment with different scenarios
to solve a similar problem.
3. Why do we need data type?
In life, we are using different data type including numbers, text, and objects.
Using the appropriate data type in our human communication is essential. We
use text (String) for names and description of information and numbers for
counting and applying mathematical calculations. We also refer to objects such
as a cup, chair, people, milk, etc. All these are data types.
Using the appropriate data type in a programming language is essential for two
reasons.
• Data types help to tell the computer processor what type of
data is expected for a specific variable and what amount of
memory space to reserve for it.
• Using appropriate data type will help programmers optimize
the use of computer memory.
You will get a better understanding of the above two points throughout this lab.
Variables
You have seen in Lab 1 that computer programming languages use variable to
represent data. For example, you may use the variable price to store the price
of an item.
float price;
The above line of code is telling the computer processor to reserve a space in
computer memory for the variable price, and that the data type will be a float.
In this example, if the programmer tried to store text in price, the compiler will
generate an error that says “incompatible data types.” Try this example.
4. Rules for naming variables
It is recommended that you use a variable name that will indicate what data will
be stored in this variable. For example, if you want to store a student grade for an
assessment, a variable name grade or quiz is better than x.
Here are the rules that you need to follow when naming variables in Java.
1. Variable names are case-sensitive.
2. It can contain Unicode letter,Digits and Two Special Characters such as
Underscore and dollar Sign.
3. Length of Variable name can be any number.
4. Its necessary to use Alphabet at the start (however we can use underscore ,
but do not use it )
5. Some auto generated variables may contain ‘$‘ sign. But try to avoid using
Dollar Sign.
6. White space is not permitted.
7. Special Characters are not allowed.
8. Digit at start is not allowed.
9. Subsequent characters may be letters, digits, dollar signs, or underscore
characters.
10. Variable name must not be a keyword or reserved word.
Exercise o correct variable names:
Write down ten different correct variable names and discuss with your
colleagues why these names are correct or not.
5. How does computer store data?
Before discussing the different data types and when a particular data type should
be used we need to examine how computer stores data. We will focus here on
numerical data.
In our daily life, we use a numerical system call decimal. The decimal system is
the numbers from 0 to infinity (both positive and negative values). Example,
0,1,2,3,4,, … etc.
However, the computer understands only 0 and 1. This computer system is
called a binary system. For example, if you store the number 25 in a variable
age.
int age = 25;
The computer will store the value 11001 as binary in computer memory. 11001
in binary is equal to 25 in the decimal system.
The binary system is presented as 2 to the power n. As you know from Math,
anything to the power zero 0 is equal to 1. The table below gives an example of
how to represent a decimal number using the binary system. Let us take the
number 25.
256 128 64 32 16 8 4 2 1
1 1 0 0 1
2 = 1
0
2 = 2
1
2 = 4
2
2 = 8
3
In the above table, the blue row represents the decimal system and the second
gray row represents the binary system. By examining the above table, you can
think of computer memory as boxes that store data in 1, 2, 4, 8, 16, etc. bits. See
the decimal row. This is why when we try to buy a USB flash disk or SD we cannot
find 7 or 9 GB memory.
In the binary row of the above table, we can enter only one digit in each cell with
0 or 1. We read this table from right to left. A value of 1 in the first cell is equal
to 1, but in the second cell it is equal to 2, the third cell is 4, etc. The value of
each cell is just twice the value of the previous cell.
Decimal
Binary
6. 256 128 64 32 16 8 4 2 1
1 1 0 0 1
2 = 1
0
2 = 2
1
2 = 4
2
2 = 8
3
1
8
16
+
+
25
Decimal
Binary
In this example, if you add values of all cells in the decimal row the values in the
binary row is 1, we get the equal decimal value to the entered binary number.
Exercises on binary system
Convert the following binary system to decimal: 11111, 101, 11000, and 101010.
You can use the above tables to
convert binary to decimal and vise
versa.
7. Using Java to convert binary to decimal
Try this code to convert binary to decimal:
Here is the explanation of the above code:
• Line 3: stores the binary number as String. Here you can enter the binary
number that you want to convert.
• Line 4: This line uses the object Integer and its function ParseInt to convert
the binary number of decimal the result is stored in the variable decimal as
an int.
• Line 5 and 4: Print the binary and its equivalent decimal number
When you run the above code you get the following results:
Now, you understand how the computer uses binary numbers to store
numerical data. In the next part of this lab, we will discuss all primitive/basic
data types available in Java.
8. Primitive Data Types
The term “Primitive Data-types” means the most basic data types available
within the Java language. There are eight primitive data types supported by
the Java Language.
The table below summarizes primitive data types support in Java Programming
Language.
There are four integer data types. An integer number is a number that does
not include and fractions (or floating point). It is a whole number. The integer
data types are a byte, short, int, and long. The main difference between these
integer data types is the size of memory space allocated to each one. Each one
has a maximum and minimum value that can be stored. For example, the byte
data type can store numbers no larger than 127 or less than -128. If you try to
store the count of students in a variable with the name nstudents and you have
more than 128 students, the following code will generate an error:
byte nstudents = 128;
The maximum and minimum values
9. The memory size allocated to byte data type is 8 bits. The first bit of the 8
bit is reserved for the sign (+ or ).
-2
7
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1
The maximum positive number that we can store in byte as a binary is
If we go back and use our previous Java code that converts binary to decimal
and we use ”1111111” as the value for the binary, we will get 128. This
means the maximum amount is 128 – 1 = 127.
Minimum value can be stored in a byte =
The minimum negative number that we can store in byte is
= -128
2- 1
7
Maximum value can be stored in a byte =
10. Exercise:
Using the table below, you need to calculate the maximum and minimum values
that can be stored in short, int, and long data types.
11. float and double data types:
The data types float, and double are used to store data with a fraction/floating
point. The size of float is 32 bits, and double is 64 bits. This is primarily why it
called double.
Also, a double data type is more precise than a float. A double variable can
provide precision up to 15 to 16 decimal/floating points as compared
to float precision of 6 to 7 decimal digits.
char data type
The char data type stores character. It required 16 bits = 2 bytes. Each char can
hold only a single character.
boolean data type
A boolean data type is used to store data with two choices: true or
false. Here is an example.
Strings, are a sequence of characters/char. In Java programming
language, strings are treated as objects and not a primitive data type.
The Java platform provides the String class to create and manipulate strings.
char sex = “M”;
String fname = “Khalid”;
Both char and String require putting data between two quotations.
boolean isMale = true;
12. Casting
Casting in programming language means converting data from one type
to another.
When do you need to use casting?
Assume that you have declared price as byte and later you want to
convert it to float because the price usually contains a floating point.
What are your options?
One option is to cast byte into a float.
Write and test this code.
Line 4 perform the casting as follows:
Data type of
the new
variable
The new
variable
Casting to
float. Note
the use of
brackets
The original
variable to
be casted
13. Issues with casting
Casting from a lower size data type to a higher size data type does not cause
any issue.
However, casting from a higher size data type to lower size data type may
result in losing data.
Assume you have stored 200 as the price of an item in a short data type and
you are trying to cast to byte.
As you know, a byte can hold the maximum value of 127. 200 is more than
127. We will lose data.
Try and check this code:
The result
As you can see, casting from short to byte results in producing the wrong results.
You will get the correct result only when the value stored in higher data type is
within the limit of the lower data type. Try to change the 200 in line 3 to 125
and run the code. You should get:
14. Exercise
Discuss the table below and complete the missing information:
Description Appropriat
e variable
name
Data Type Rationale for selecting this data
type
Price of items
in a
supermarket
Number of
registered cars
in UAE
Student mark
for an exam
The balance of
a bank
account (think
of Bill Gates
account)
A student full
name
The result of a
student in an
exam as pass
or fail
15. A thematic Operators
To perform a mathematical calculation in programming Languages, you need
to use the appropriate arithmetic operators. You are expected to be familiar
with these athematic operators as you have used them in mathematics to do
addition, subtraction, multiplication, and division. In Java, there are specific
symbols that you have to use to perform to the correct calculation. The table
below summarizes these operators. Assume A is 10 and B is 20.
In Java, if you want to raise a number to the power of some other number, then
you need to import java.lang.Math and use the function pow. Here is an example
that raises 20 to the power 3.
16. Precedence of Java Operators
Operator precedence determines the sequence of expression/calculation. The
word expression refers to the calculation or the formula used to perform the
calculation. An expression may include constants, variables, operators, and
functions. The precedence of Java operators decides how an expression is
evaluated.
Certain operators have higher precedence than others; for example, the
multiplication operator has higher precedence/priority than the addition operator
−
For example, x = 20 + 4 * 2; here x is assigned 28, not 48 because operator * has
higher precedence than +, so it first gets multiplied with 4 * 2 and then adds into
20.
Here, operators with the highest precedence appear at the top of the table, those
with the lowest look at the bottom. Within an expression, higher precedence
operators will be evaluated first.
If you want to force any calculation to be performed first, then you have to
include it between brackets. Here is our same example:
x = (20+4)*2
The result will be 48. The computer will give priority for (20+4), and the result
will be multiplied by 2.
17. Exercises:
1. Write a program that would calculate and output the area of a triangle. Assume base and
height are initialized to 10 and 8 in the program.
Hint: area of a triangle is its base multiplied by its height divided by two.
2. Modify question 3 so that the program accepts the base and height in centimeters from the
user. The program then calculates and outputs the area of the triangle.
3. Write a program to convert Fahrenheit to Celsius temperature and output the result on the
screen.
Hint: Celsius = (Fahrenheit – 32) * 5/9
4. Write a program to prompt the user to enter a value for an amount of money in US dollar.
The program should then convert the amount entered to UAE dirham and output the result
on the screen. Assume one US dollar is AED 3.7
5. The over time rate for a company operating in the UAE is 1.5 times the normal rate. Write a
program to ask the operator to enter the normal rate in UAE dirham, the number of hours
worked at normal rate, and the number of hours worked at overtime rate. The program
should then calculate the gross salary and display the result on the screen.
6. Write a program that asks the user to enter the number of DVDs that he wishes to rent and
the charge of renting a DVD, and then calculates the total charge that he should pay.
7. Write a program that will calculate and display the average mark of 3 different tests. The
program should ask the student to enter the 3 marks first and then display the result.
8. Ahmed wishes to buy 3 books from a bookshop that offers 10% discount on books. Write a
program that asks Ahmed to enter the price of each book and then calculates and displays
the amount of money that he should pay.
9. Salem bought a laptop and printer from a shop that offers discounts on some products. The
original prices of the laptop and printer were 3900 AED and 800 AED respectively. Salem
managed to get 15% discount on the laptop and 10% discount on the printer. Write a
program to find out the amount of money that Salem paid for both items.
10. A family of 4 (husband, wife, 3 years old son and 10 months old daughter). They have
decided to visit Egypt during the Eid break. For the children he will pay 60% and 10% of the
normal ticket price for his son and daughter respectively. Write an algorithm that asks the
husband to enter the price of the air ticket and then calculates and displays the amount of
money he should pay for the 4 tickets.
Complete the following exercises: