Self- Check 1
Which of the following are Pascal reserved words, standard identifiers, valid identifiers, invalid identifiers?
end ReadLn Bill
program Sues‟s Rate
Start begin const
Y=Z Prog#2 &Up
First Name „MaxScores‟ A*B
CostaMesa,CA Barnes&Noble CONST
XYZ123 ThisIsALongOne 123XYZANSWER
ANSWERS
Paschal reserved words:
begin, end, program, Start, CONST, const
Standard identifiers:
ReadLn, „MaxScores‟, Bill, Rate
Valid identifiers:
XYZ123, ThisIsALongOne, A*B, Y=Z, CostaMesa, CA, First Name
Invalid identifiers:
123XYZ, Sues‟s, &UpFirstName, Barnes&Noble, Prog#2
Self- Check 2
Which of the following literal values are legal and what are their types? Which are illegal and why?
15 „XYZ‟ „*‟
$25.123 15; -999
.123 „x‟ “X”
„9‟ „-5‟ True
ANSWER:
The following values are legal and their type
Legal
Type
Illegal
15
Integer literal
$25.123
„XYZ‟
String Literal
.123
„X‟
Character Literal
„9‟
True
Boolean Literal
15;
-999
Integer Literal
-„5‟
Operator literal
„*‟
TP- Lecture 4.2
Self- Checked 1
Which of the following are valid program headings? Which are invalid and why?
(i) Program program; - INVALID using reserved ID
(ii) program 2ndCourseInCS; -INVALID because starts with digit
(iii) program PascalIsFun;- VALID program heading
(iv) program Rainy Day; -INVALID – contains space
Self- Checked 2
Rewrite the following code so that it has no syntax errors and follows the writing conventions we adopted
(i) Program SMALL;
VAR X, Y, Z : real;
BEGIN
Y := 15.0;
Z := -Y + 3.5;
X :=Y + z;
writeln (x, Y, z);
END.
ANSWER:
Program
Learn about current initiatives in digital and media literacy in five countries: Turkey Brazil, Russia, Israel and the United States in this panel discuss from #ISTE2014 in Atlanta featuring Renee Hobbs and Media Education Lab scholars.
Learn about current initiatives in digital and media literacy in five countries: Turkey Brazil, Russia, Israel and the United States in this panel discuss from #ISTE2014 in Atlanta featuring Renee Hobbs and Media Education Lab scholars.
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
This slide includes: Control Flow and Functions.
That is Boolean values and operators.
It include Iteration,Fruitful functions,Scope of Variable and Modules.
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAMSaraswathiRamalingam
Fundamental Algorithms, Exchanging the values of Two Variables,Counting,Summation of a Set of Numbers,Factorial Computation ,Sine Function Computation ,Generation of the Fibonacci Sequence,Reversing the Digits of an Integer,Base Conversion , Character to Number Conversion , Factoring Methods: Finding the square Root of a Number ,The Smallest Divisor of an Integer,The Greatest Common Divisor of the two integers,Generating Prime Numbers,Computing the Prime Factors of an integer ,Generation of Pseudo,random Numbers,Raising a Number to a Large Power,Computing the nth Fibonacci Number,thiruvalluvar university syllabus,unit 5,computer science basics,new syllabus,programming in c,example program in c,
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
The design of Farm cart 0011 report 1 2020musadoto
This report describes the best designing of a 200cc FARM CART MACHINE which will be useful to the farm fields due to the fact that, the purchase, repair and maintenance are affordable to all level of income earners. Despite the cost effectiveness of the machine, the report also tries to justify that the machine can be used multipurposely as it serves the purposes of been used as farm transport, mowering machine, boom spraying and or mini planter with two rows. All these can be achieved as long as the implements are attached with respect to the power capacity of the farm cart.
The report tells only the design and testing of machine excluding its farm implements design. Some best reviews from other study projects done by other people in the world provided a good reference for designing and implementation of this project. The project is initially costly because it needs to develop a prototype and test the different first ideas.
The project report describes the important of choosing to use the designed farm cart machine compared to other farm machines at the market which are most efficiently to be used by farmers in their fields.
The challenges are inevitable in any project, here in designing of this 200cc farm machine, the major issue is the funding because the fund for this project is from the pocket which is always insufficient as it depends to the meals and accommodation money distribution sponsored from the HIGH EDUCATION STUDENTS LOAN BOARD (HESLB) thus it takes longer to accomplish the project by waiting another quarter of the semester to continue with the project which affects the other part of normal life(in terms of meals and accommodation).
The report recommends that, the department of engineering sciences and technology and Sokoine University of Agriculture as a whole should invest into this technology by utilizing fully the idea and funding the project for more better improvement so as to attain the desired standard that can with stand the different farm field factors. These when taken into consideration there is a possibility to achieve the industrialization policy in our country and thereafter it is a better approach to modern agriculture.
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
This slide includes: Control Flow and Functions.
That is Boolean values and operators.
It include Iteration,Fruitful functions,Scope of Variable and Modules.
PROGRAMMING IN C EXAMPLE PROGRAMS FOR NEW LEARNERS - SARASWATHI RAMALINGAMSaraswathiRamalingam
Fundamental Algorithms, Exchanging the values of Two Variables,Counting,Summation of a Set of Numbers,Factorial Computation ,Sine Function Computation ,Generation of the Fibonacci Sequence,Reversing the Digits of an Integer,Base Conversion , Character to Number Conversion , Factoring Methods: Finding the square Root of a Number ,The Smallest Divisor of an Integer,The Greatest Common Divisor of the two integers,Generating Prime Numbers,Computing the Prime Factors of an integer ,Generation of Pseudo,random Numbers,Raising a Number to a Large Power,Computing the nth Fibonacci Number,thiruvalluvar university syllabus,unit 5,computer science basics,new syllabus,programming in c,example program in c,
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
Similar to BASICS OF COMPUTER PROGRAMMING-TAKE HOME ASSIGNMENT 2018 (20)
The design of Farm cart 0011 report 1 2020musadoto
This report describes the best designing of a 200cc FARM CART MACHINE which will be useful to the farm fields due to the fact that, the purchase, repair and maintenance are affordable to all level of income earners. Despite the cost effectiveness of the machine, the report also tries to justify that the machine can be used multipurposely as it serves the purposes of been used as farm transport, mowering machine, boom spraying and or mini planter with two rows. All these can be achieved as long as the implements are attached with respect to the power capacity of the farm cart.
The report tells only the design and testing of machine excluding its farm implements design. Some best reviews from other study projects done by other people in the world provided a good reference for designing and implementation of this project. The project is initially costly because it needs to develop a prototype and test the different first ideas.
The project report describes the important of choosing to use the designed farm cart machine compared to other farm machines at the market which are most efficiently to be used by farmers in their fields.
The challenges are inevitable in any project, here in designing of this 200cc farm machine, the major issue is the funding because the fund for this project is from the pocket which is always insufficient as it depends to the meals and accommodation money distribution sponsored from the HIGH EDUCATION STUDENTS LOAN BOARD (HESLB) thus it takes longer to accomplish the project by waiting another quarter of the semester to continue with the project which affects the other part of normal life(in terms of meals and accommodation).
The report recommends that, the department of engineering sciences and technology and Sokoine University of Agriculture as a whole should invest into this technology by utilizing fully the idea and funding the project for more better improvement so as to attain the desired standard that can with stand the different farm field factors. These when taken into consideration there is a possibility to achieve the industrialization policy in our country and thereafter it is a better approach to modern agriculture.
CONSTRUCTION [soil treatment, foundation backfill, Damp Proof Membrane[DPM] a...musadoto
With reference to a construction site visited recently, describe in details key features
that can be observed on site as follows
Foundations backfilling, hardcore, soil treatment, DPM and BRC works prior
to pouring oversite concrete
CONSTRUCTION [soil treatment, foundation backfill, Damp Proof Membrane[DPM] and BRC for engineers (civil)
ENGINEERING SYSTEM DYNAMICS-TAKE HOME ASSIGNMENT 2018musadoto
1. Read Chapter 4 – System Dynamics for Mechanical Engineers by Matthew Davies and Tony L. Schmitz and implement Examples 4.1 to 4.12 in Matlab.
2. Read Chapter 7 – System Dynamics for Mechanical Engineers by Matthew Davies and Tony L. Schmitz and implement Examples 7.1 to 7.11 in Matlab.
3. Read Chapter 9 – System Dynamics for Mechanical Engineers by Matthew Davies and Tony L. Schmitz and implement Examples 9.1 to 9.6 in Matlab.
4. Read Chapter 11 – System Dynamics for Mechanical Engineers by Matthew Davies and Tony L. Schmitz and implement Examples 11.1 to 11.7 in Matlab.
5. Read Chapter 2 - System Dynamics for Engineering Students: Concepts and Applications by Nicolae Lobontiu and attempt problem 2.18 (page 63).
6. Read Chapter 3 - System Dynamics for Engineering Students: Concepts and Applications by Nicolae Lobontiu and attempt problem 3.13 (pp 98 - 100).
7. Read Chapter 4 - System Dynamics for Engineering Students: Concepts and Applications by Nicolae Lobontiu and attempt problem 4.20 (page 146).
8. Read Chapter 5 - System Dynamics for Engineering Students: Concepts and Applications by Nicolae Lobontiu and attempt problems 5.15 (page 198), 5.21 (pp 199 - 200) and 5.27 (pp 201 – 202).
Hardeninig of steel (Jominy test)-CoET- udsmmusadoto
Controlling a material’s properties during processing is pivotal for any engineering field. A specific hardness for a metal is often a desirable characteristic for many applications, so controlling hardness is important during processing. To increase the hardness of steel, it is often quenched from a high temperature to form martensite, a hard yet brittle phase of iron. The extent of martensite formation, including hardness and depth of formation, is known as hardenability. This practical provides an experiment for measurement of hardenability in plain carbon steel and an alloyed steel according to, the Jominy End-Quench Test , (ASTM A255 – 10). The demonstration exercise involve quenching one end of a heated steel sample ,comparing and evaluating the hardness distribution using measurements obtained at different locations(distance interval) on the sample(specimens) surface.
1.1 The aim of the experiment
The aim of the experiment is to test the usefulness of the ultrasonic waves, by passing them through different
solids one can find out a lot of physical properties like young’s modulus , defects, Poisson ratio, Velocity of
sound in respective material this is due to the response of the received ultrasonic waves.
1.2 Theory of experiment
Ultrasonic testing (UT) is a family of non-destructive testing (NDT) techniques based on the propagation of ultrasonic waves in the object or material tested. In most common UT applications, very short ultrasonic pulse-waves with center frequencies ranging from 0.1-15 MHz, and occasionally up to 50 MHz, are transmitted into materials to detect internal flaws or to characterize materials. A common example is ultrasonic thickness measurement, which tests the thickness of the test object, for example, to monitor pipework corrosion.
Ultrasonic testing is often performed on steel and other metals and alloys, though it can also be used on concrete, wood and composites, albeit with less resolution. It is used in many industries including steel and aluminium construction, metallurgy, manufacturing, aerospace, automotive and other transportation sectors.
Ae 219 - BASICS OF PASCHAL PROGRAMMING-2017 test manual solutionmusadoto
Whether the Pascal program is small or large, it must have a specific structure. This
program consists mainly of one statement (WRITELN) which does the actual work
here, as it displays whatever comes between the parentheses. The statement is
included inside a frame starting with the keyword BEGIN and ending with the keyword
END. This is called the program main body (or the program block) and usually
contains the main logic of data processing.
1. The background of Fluid Mechanics
2. Fields of Fluid mechanics
3. Introduction and Basic concepts
4. Properties of Fluids
5. Pressure and fluid statics
6. Hydrodynamics
Fluid mechanics (a letter to a friend) part 1 ...musadoto
1. The background of Fluid Mechanics
2. Fields of Fluid mechanics
3. Introduction and Basic concepts
4. Properties of Fluids
5. Pressure and fluid statics
6. Hydrodynamics
Fluids mechanics (a letter to a friend) part 1 ...musadoto
1. The background of Fluid Mechanics
2. Fields of Fluid mechanics
3. Introduction and Basic concepts
4. Properties of Fluids
5. Pressure and fluid statics
6. Hydrodynamics
Fresh concrete -building materials for engineersmusadoto
CONCRETE
is a building Material made from a mixture of gravel ,sand ,cement,water and air ,forming a stone like mass on hardenning.
FRESH CONCRETE
It is a concrete that has not reached the final setting time.
Course Contents:
Introduction; Linear measurements; Analysis and adjustment of measurements, Survey methods: coordinate systems, bearings, horizontal control, traversing, triangulation, detail surveying; Orientation and position; Areas and volumes; Setting out; Curve ranging; Global Positioning system (GPS); Photogrammetry.
Fresh concrete -building materials for engineersmusadoto
General introduction
CONCRETE
is a building Material made from a mixture of gravel ,sand ,cement,water and air ,forming a stone like mass on hardenning.
FRESH CONCRETE
It is a concrete that has not reached the final setting time.
DIESEL ENGINE POWER REPORT -AE 215 -SOURCES OF FARM POWERmusadoto
The diesel engine (also known as a compression-ignition or CI engine), named after Rudolf Diesel, is an internal combustion engine in which ignition of the fuel which is injected into the combustion chamber is caused by the elevated temperature of the air in the cylinder due to mechanical compression (adiabatic compression). Diesel engines work by compressing only the air. This increases the air temperature inside the cylinder to such a high degree that atomised diesel fuel that is injected into the combustion chamber ignites spontaneously. This contrasts with spark-ignition engines such as a petrol engine (gasoline engine) or gas engine (using a gaseous fuel as opposed to petrol), which use a spark plug to ignite an air-fuel mixture. In diesel engines, glow plugs (combustion chamber pre-warmers) may be used to aid starting in cold weather, or when the engine uses a lower compression-ratio, or both. The original diesel engine operates on the "constant pressure" cycle of gradual combustion and produces no audible knock.
A diesel engine built by MAN AG in 1906
Detroit Diesel timing
Fairbanks Morse model 32
The diesel engine has the highest thermal efficiency (engine efficiency) of any practical internal or external combustion engine due to its very high expansion ratio and inherent lean burn which enables heat dissipation by the excess air. A small efficiency loss is also avoided compared to two-stroke non-direct-injection gasoline engines since unburned fuel is not present at valve overlap and therefore no fuel goes directly from the intake/injection to the exhaust. Low-speed diesel engines (as used in ships and other applications where overall engine weight is relatively unimportant) can have a thermal efficiency that exceeds 50%.[1][2
Farm and human power REPORT - AE 215-SOURCES OF FARM POWER musadoto
Farm is an area of land and its building, used for growing crops a rearing of animals or an area of land
that is devoted primarily of agricultural process with the primary objective of producing food and other
commercial crops. Or an area of water that is devoted primarily to agricultural process in order to
produce and manage such commodities as fibers, grains, livestock or fuel.
The process of working the ground, planting seeds and growing of planting known as farming.it can
described s raising of animals for milk and meat as farming.
ENGINE POWER PETROL REPORT-AE 215-SOURCES OF FARM POWERmusadoto
What is an Engine?
Before knowing about how the Petrol Engine works, let's first understand what an engine is. This is common for both petrol and diesel engines alike. An engine is a power generating machine which converts potential energy of the fuel into heat energy and then into motion. It produces power and also runs on its own power.
The engine generates its power by burning the fuel in a self-regulated and controlled „Combustion‟ process. The combustion process involves many sub-processes which burn the fuel efficiently and results in the smooth running of the engine.
These processes include:
The suction of air (also known as breathing or aspiration).
Mixing of the fuel with air after breaking the liquid fuel into highly atomized / mist form.
Igniting the air-fuel mixture with a spark (petrol engine).
Burning of highly atomized fuel particles which results in releasing / ejection of heat energy.
How does an Engine work?
The engine converts Heat Energy into Kinetic Energy in the form of „Reciprocating Motion‟. The expansion of heated gases and their forces act on the engine pistons. The gases push the pistons downwards which results in reciprocating motion of pistons.
This motion of the piston enables the crank-shaft to rotate. Thus, it finally converts the reciprocating motion into the 'Rotary motion' and passes on to wheels.
A petrol engine (known as a gasoline engine in American English) is an internal combustion engine with spark-ignition, designed to run on petrol (gasoline) and similar volatile fuels.
In most petrol engines, the fuel and air are usually mixed after compression (although some modern petrol engines now use cylinder-direct petrol injection). The pre-mixing was formerly done in a carburetor, but now it is done by electronically controlled fuel injection, except in small engines where the cost/complication of electronics does not justify the added engine efficiency. The process differs from a diesel engine in the method of mixing the fuel and air, and in using spark plugs to initiate the combustion process. In a diesel engine, only air is compressed
TRACTOR POWER REPORT -AE 215 SOURCES OF FARM POWER 2018musadoto
A tractor is an engineering vehicle specifically designed to deliver a high tractive effort (or torque) at slow speeds, for the purposes of hauling a trailer or machinery used in agriculture or construction. Most commonly, the term is used to describe a farm vehicle that provides the power and traction to mechanize agricultural tasks, especially (and originally) tillage, but nowadays a great variety of tasks. Agricultural implements 0may be towed behind or mounted on the tractor, and the tractor may also provide a source of power if the implement is mechanised.
The word Tractor is derived prior to 1900, the Machine were known as traction motor (pulling-machine).After the year 1900 both the words are joined by taking ‘Tract’ from Traction and ‘Tor” from motor calling it a Tractor.
In our Country tractors were started manufacturing in real sense after independence and at present we are self-sufficient in meeting demand of country’s requirement for tractors. Our country is basically an agricultural country where 75% of our population is directly or indirectly connected with agriculture. This cannot be produced with our conventional bullock pulled agricultural implements. Tractor is one of the basic agricultural machines
used for speeding up agriculture production.
WIND ENERGY REPORT AE 215- 2018 SOURCES OF FARM POWERmusadoto
Wind is the flow of gases on large scale. On the surface of the earth, wind consists of the bulk movement of air. In outer space, solar wind is the movement of gases and charged particles from the sun though space, while planetary wind is the outgassing of light chemical from a planet’s atmosphere into space. Wind by their spatial scale, their speed, the type of force that cause them, the region in which they occur and their effect. The strongest observed winds on planet in solar system occur on Neptune and Saturn. Winds have various aspects, an important one being its velocity, density of the gas involved and energy content of the wind.
Wind is almost entirely caused by the effects of the sun which, each hour, delivers 175 million watts of energy to the earth. This energy heats the planet’s surface, most intensively at the equator, which causes air to rise. This rising air creates an area of low pressure at the surface into which cooler air is sucked, and it is this flow of air that we know as “wind”. In reality atmospheric circulation is much more complicated and, after rising at the equator air travels pole wards. As it travels the air cools and eventually descends to the earth’s surface at about 30° latitude (north and south), from where it returns once again to the equator (a closed loop known as a Hadley Cell). Similar cells exist between 30° and 60° latitude (the Ferrell Cells) and between 60° latitude and each of the poles (the Polar Cells). Within these cells, the flow of air is further impacted by the rotation of the earth or the "Coriolis Effect". This effect creates a sideways force which causes air to circulate anticlockwise around areas of low pressure in the northern hemisphere and clockwise in the southern hemisphere
In summary, the origin of winds may be traced basically to uneven heating of the earth’s surface due to sun. This may lead to circulation of widespread winds on a global basis, producing planetary winds or may have a limited influence in a smaller area to cause local winds.
Water power or Hydropower is power derived from the energy of free falling water which may
be harnessed for useful purposes. Hydroelectricity is the term referring to electricity generated
by hydropower which implies the production of electrical power through the use of the
gravitational force of falling or flowing water. It is the most widely used form of renewable
energy, accounting for 16 percent of global electricity generation..The cost of hydroelectricity is
relatively low, making it a competitive source of renewable electricity. The average cost of
electricity from a hydro plant larger than 10 megawatts is 3 to 5 U.S. cents per kilowatthour.
Hydro is also a flexible source of electricity since plants can be ramped up and down very
quickly to adapt to changing energy demands. However, damming interrupts the flow of rivers
and can harm local ecosystems, and building large dams and reservoirs often involves displacing
people and wildlife. Once a hydroelectric complex is constructed, the project produces no direct
waste, and has a considerably lower output level of the greenhouse gas carbon dioxide (CO2)
than fossil fuel powered energy plants.
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Planning Of Procurement o different goods and services
BASICS OF COMPUTER PROGRAMMING-TAKE HOME ASSIGNMENT 2018
1. SOKOINE UNIVERSITY OF AGRICULTURE
COLLEGE OF AGRICULTURE
DEPARTMENT OF ENGINEERING SCIENCE AND TECHNOLOGY
AE 219
BASICS OF COMPUTER PROGRAMMING
GROUP 09-ASSIGNMENT, IWRE 2
NO. NAME OF A STUDENT REGISTRATION NUMBER SIGNATURE
1. DOTO, MUSA GESE IWR/D/2016/0011
2. KOYI, PERIS J IWR/D/2016/0021
3. KWEKA, DANIEL IWR/D/2016/0023
4. DAUDI, DERICK IWR/D/2016/0009
5. KILINDO, ABUBAKARI IWR/D/2016/0065
INSTRUCTOR: DR. BAANDA A. SALIM
SUBMISSION DATE: FRIDAY ,29TH
JUNE 2018
2. PART 1
TP- Lecture 4.1
Self- Check 1
Which of the following are Pascal reserved words, standard identifiers, valid identifiers, invalid
identifiers?
end ReadLn Bill
program Sues‟s Rate
Start begin const
Y=Z Prog#2 &Up
First Name „MaxScores‟ A*B
CostaMesa,CA Barnes&Noble CONST
XYZ123 ThisIsALongOne 123XYZANSWER
ANSWERS
Paschal reserved words:
begin, end, program, Start, CONST, const
Standard identifiers:
ReadLn, „MaxScores‟, Bill, Rate
Valid identifiers:
XYZ123, ThisIsALongOne, A*B, Y=Z, CostaMesa, CA, First Name
Invalid identifiers:
123XYZ, Sues‟s, &UpFirstName, Barnes&Noble, Prog#2
Self- Check 2
Which of the following literal values are legal and what are their types? Which are illegal and
why?
15 „XYZ‟ „*‟
$25.123 15; -999
.123 „x‟ “X”
„9‟ „-5‟ True
3. ANSWER:
The following values are legal and their type
Legal Type Illegal
15 Integer literal $25.123
„
XYZ‟ String Literal .123
„X‟ Character Literal „9‟
True Boolean Literal 15;
-999 Integer Literal -„5‟
Operator literal „*‟
TP- Lecture 4.2
Self- Checked 1
Which of the following are valid program headings? Which are invalid and why?
(i) Program program; - INVALID using reserved ID
(ii) program 2ndCourseInCS; -INVALID because starts with digit
(iii) program PascalIsFun;- VALID program heading
(iv) program Rainy Day; -INVALID – contains space
Self- Checked 2
Rewrite the following code so that it has no syntax errors and follows the writing conventions we
adopted
(i) Program SMALL;
VAR X, Y, Z : real;
BEGIN
Y := 15.0;
Z := -Y + 3.5;
X :=Y + z;
writeln (x, Y, z);
END.
ANSWER:
Program SMALL;
VAR
X, Y, Z :real;
BEGIN
Y := 15.0;
Z := -Y + 3.5;
x := Y + z;
writeln (x, Y, z);
END.
4. (ii) PROGRM 2time5 {input,output};
CONST two := 2; five := 5;
VAR multip; dummy ; integer;
BEGIN ;
multip = two * five ; dummy := multip ;
write (two) , write (five)
END ;
ANSWER:
PROGRAM p2time5(INPUT,OUTPUT);
CONST
two = 2;
five = 5;
VAR
multip, dummy :integer;
BEGIN
multip := two * five ;
dummy := multip ;
write (dummy)
END .
Self- Check 3
Write the following numbers in normal decimal notation:
(i) 103E-4 = 0.0103
(ii) 1.2345E+6 = 1234500000.0
(iii) 123.45E+3 = 123450.0
Self-Check 4
Write the following numbers in Pascal scientific notation
(i) 1300= 1.3E+3
(ii) 123.45= 1.2345E+2
(iii) 0.00426= 4.26E-3
TP- Lecture 5.1
Self- Checked 1
What are the results of the following expressions?
22 div 7 = 3
7 div 22 = 0
22 mod 7 =1
7 mod 22 = 7
5. Self- Checked 2
What is valid & what is invalid in the following
const PI = 3.14159;
MaxI = 1000;
var
X, Y : Real;
A, B, I : Integer;
. . .
I := A mod B; I := A mod Y;
X := A / B; I := A / B; X := A / Y;
I := B div 0; I := A mod 0; X := PI div Y;
X := A mod (A / B);
I := (MaxI - 990) div A;
I := A mod (MaxI - 990);
SEE TURBO PASCAL COMPILATION ERRORS
ANSWER:
PROGRAM Types;
CONST PI = 3.14159;
MaxI = 1000;
VAR
X, Y : Real;
A, B, I : Integer;
BEGIN
I := A mod B;{ I := A mod Y; }
X := A / B; { I := A / B; }
X := A / Y; { I := B div 0; }
I := A mod 0; { X := PI div Y; }{ X := A mod (A / B); }
I := (MaxI - 990) div A;
I := A mod (MaxI - 990);
END.
TP- Lecture 5.2
Self- Checked 1:
What is the output if the entered data are 5 7?
writeln („Enter two integers>‟);
readln(M, N);
M := M + 5;
N := 3 + N;
writeln („M = „, M);
writeln („N = „, N);
6. ANSWER:
The output of the program is
Enter two intergers>5 7
M= 10
N= 10
Self- Checked 2:
What is the output of this code?
write („My name is‟);
writeln („Doe, Jane‟);
writeln ;
write(„I live in „);
write(„Ann Arbor, MI‟);
writeln („and my zip code is „, 48109);
ANSWER:
The output of this code will be,
My name is Doe, Jane
I live in Ann Arbor, MIA
and my zip code is 48109
Self- Checked 3:
Show how the value -15.564 (stored in X) would be displayed using the following formats
(i) X :8:4= -15.5640
(ii) X:8:3 = -15.564
(iii) X:8:1 = -15.6
(iv) X:8:0 = -16.0
(v) X:8 = -15
Self- Checked 4:
Assuming X = 12.345 (type Real) and I = 100 (type Integer). What will the output of the
following statements look like?
writeln(„X is „ :10, X :6:2, „I is „ :4, I :5);
write(„I is „ :10, I : 1);
writeln(„X is „ :10, X :2:1);
7. ANSWER:
The output will be as follows
X is 12.35 I is 100
I is 100 X is 12.4
TP- Lecture 8
Self- Checked 1:
(i) Write the Boolean expression to check if a character variable Ch is a digit.
ANSWER:
(ORD(InputChar) > 47) AND (ORD(InputChar) < 58)
(ii) Write a Boolean expression to check if a character variable Chis an upper-case letter.
ANSWER:
(ORD(InputChar) > 64 ) AND (ORD(InputChar) < 91)
iii. Write a Boolean expression to check if a character variable Ch is a lower-case letter.
ANSWER:
(ORD(InputChar) > 96 ) AND (ORD(InputChar) < 123)
iv. Using a Boolean test, convert upper-case character Ch to a lower-case character.
ANSWER:
IF Upper-case THEN
Name[I] := CHR(ORD(Name[I])+32);
Self- Check 2:
Write Boolean assignment statements:
1. Assign true to variable Between if the value of N is in the range -K to +K, inclusive;
otherwise, assign a value of false
ANSWER:
Boolean assignment statement is,
IF (N <= -k) AND (N <=+k)
WRITELN(„This is True‟)
ELSE
WRITELN(„This is False‟)
8. (a) Assign a value of true to variable Uppercase if Ch is an uppercase letter;
otherwise, assign false
ANSWER:
Boolean statement is,
IF M DivN THEN
WRITELN („This is True‟)
ELSE
WRITELN(„This is False)
(b) Assign a value of true to variable Divisor if M is a divisor of N; otherwise,
assign false
ANSWER:
Boolean statement is,
IF (ORD(InputChar) > 64 ) AND (ORD(InputChar) <
91) THEN
WRITELN(„This is True‟)
ELSE
WRITELN(„This is False‟)
Self- Check 3:
What do these statements display?
(i) IF 12 < 12 THEN
writeln(„Less‟)
ELSE
writeln(„Not less‟)
ANSWER:
It will display,
Not less
(ii) Var1 := 25.12;
Var2 := 15.00;
IF Var1
(iii) <= Var2 THEN
writeln(„Less or equal‟)
ELSE
writeln(„Greater than‟)
ANSWER:
It will display, Greater than
9. Self- Check 4:
What value is assigned to X when Y is 15.0?
a. X := 25.0;
IF Y <> (X - 10.0) THEN
X := X - 10.0
ELSE
X := X / 2.0
ANSWER: The value assigned to X is 12.5
b. IF (Y < 15.0) AND (Y >= 0.0) THEN
X := 5 * Y
ELSE
X := 2 * Y
c. ANSWER
The value assigned to X is 30.0
Self- checked 5:
Write Pascal statements to perform the following:
If Item is nonzero, then multiply Product by Item and save the result
in Product; otherwise, skip the multiplication. In either case, print the
value of Product.
Store the absolute difference of X and Y in Y, where the absolute
difference is (X - Y) or
(Y - X), whichever is positive.
Don’t use the abs() function in your solution
ANSWER:
IF item <> 0 THEN
Multip = product*item
WRITELN;
WRITELN(„Product‟)
Self-Check 6:
Evaluate the following expressions, with and without short-circuit evaluation
-Assumptions:
i. X = 6
ii. Y = 7
-(X > 5) and (Y div X <= 10)
-(X <= 10) or (X / (Y - 7) > 3)
10. ANSWER:
With short circuit
X = 6
Y = 7
IF (X >5) AND (YdivX<=10)
IF(X<= 10) OR (X/(Y-7)>3)
Without shot circuit-evaluation
X = 6
Y = 7
IF (X > 5) THEN
(Y divX<= 10)
IF (X <= 10) THEN
(X/(Y-7) > 3)
TP-Lecture 9
Self- Checked 5.1:
Trace the following program fragment:
J := 10;
FOR I := 1 to 5 DO
BEGIN
writeln(I, J);
J := J - 2
END; { FOR }
• How many times will the loop body be executed?
ANSWER:
The loop body will be executed 5 times.
Self- Checked 5.2
(a) Write FOR loop headers that process all values of Celsius (type integer) in the following
ranges:
-10 through +10
100 through 1
15 through 50
50 through -75
(b) What types can be used as FOR loop counters?
11. (c) Write a FOR statement that computes the sum of the ODD integers in the range 0 to
100 inclusive
ANSWER:
FOR Celcius := -10 TO 10 DO
FOR Celcius := 100 DOWN TO 1 DO
FOR Celcius := 15 TO 50 DO
FOR Celcius := 50 DOWN TO -75DO
Self- Check 5.3:
For the following loop:
X := 3;
Count := 0;
while Count < 3 do
begin
X := X * X;
writeln(X);
Count := Count + 1
end; { while }
writeln(Count);
• How many times is the loop body repeated?
• What is printed during each repetition of the loop body, and at the very end?
• What happens if the last statement in the loop body is: Count := Count + 2;
• What happens if the last statement in the loop body is removed?
ANSWER:
The time that the loop body repeated are 3 time
The result which can be printed during each repeation of the
loop is 0
When the last statement in the loop is count:= count+2 =215
can be printed
When the last statement in the loop body is removed Nothing
will be printed
Self-Checked 5.10:
(i) Write a while loop that displays each integer from 1 to 5 on a separate line, along with its
square.
(ii) Write a while loop that displays each integer from 4 down to -6 on a separate line. Display
the values in the sequence 4, 2, 0, and so on.
12. ANSWER
NOT(X <= Y) OR (X <> 15)
NOT(X <= Y) AND (Z = 7.5)
NOT(X <> 15) AND (Z = 7.5)
NOT Flag AND (X <> 15.7)32
Flag OR NOT (x <= 8)
TP- Lecture 11.1
Self- Checked 1:
What is displayed by the following program fragment, assuming N is 5?
FOR I := 1 TO N DO
BEGIN
FOR J := 1 TO I DO
write(„*‟);
writeln
END;
ANSWER:
- The display that the program can produce are
*
* *
* * *
* * * *
* * * * *
Self- Checked 2 :
What is displayed by the following program fragment, assuming
M is 3 and N is 5?
FOR I := N DOWNTO 1 DO
BEGIN
FOR J := M DOWNTO 1 DO
write(„*‟);
writeLn
END;
13. ANSWER:
The display that the program can execute are
* * *
* * *
* * *
* * *
Self-checked 3:
Show the output printed by the following nested loops:
FOR I := 1 TO 2 DO
BEGIN
writeln(„Outer‟ : 5, I : 5);
FOR J := 1 TO 3 DO
writeln(„Inner‟ : 7, I : 3, J : 3)
FOR K := 2 DOWNTO 1 DO
writeln(„Inner‟ :7, I : 3, K : 3)
END;
ANSWER:
The output that can be printed in the nested loop are
OUTPUT 1
Inner 1 1
Inner 1 2
Inner 1 3
Inner 1 2
Inner 1 1
OUTPUT 2
Inner 2 1
Inner 2 2
Inner 2 3
Inner 2 2
Inner 2 1
Self- Check 4:
Write a program fragment that, given an input value N, displays N rows in the form 1 2 ... N, 2 3
... N + 1, and so forth
PROGRAM Check;
VAR I,J,N : integer;
BEGIN
write('What is N? ');
read(N);
FOR I := 1 TO N DO
BEGIN
FOR J := I TO I + N - 1 DO
write(J:2);
14. writeln
END;
readln
END.
ANSWER:
PROGRAM Fragment(INPUT,OUTPUT);
VAR
J, I, N :INTEGER;
BEGIN
WRITE(„Enter the value of N‟);
READLN(N);
FOR
I := 1 TO N DO
BEGIN
FOR J := I TO I +N-1 DO
WRITE(J : 2)
WRITELN;
READLN
END.
Self- Check 5:
Write a program that prints a nicely labeled multiplication table for the digits 1 through 9.
ANSWER:
PROGRAM MultiplicationTable;
VAR I,J : integer;
BEGIN
FOR I := 1 TO 9 DO
BEGIN
FOR J := 1 TO 9 DO
write(I*J:3);
writeln
END;
readln
END.
15. The outputs of the program are
1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81
TP- Lecture 12.2
Self- Check 1:
What is wrong with this program?
assign(„MyData.txt‟, InFile);
rewrite(Infile); /* ?? */
reset(Infile);
WHILE NOT eoln DO /* ?? */
BEGIN
read(InFile, Next);
write(Next)
END; {while}
ANSWER:
The wrong of this statement can be corrected as
PROGRAM Self(OUTPUT);
VAR
InFile : TEXT;
16. BEGIN
Assign(InFile, „MyData.Txt‟);
Rewrite(InFile);
WHILE NOT eoln (inFile) DO
BEGIN
WRITE( Next);
READLN(Infile,Next);
END; {WHILE};
READLN;
Reset(InFile)
END.
PART II.
QUESTION 1
In the following program, two integers, a and b, are declared in the declaration part, then
assigned integer values in the program block. The WRITELN statement is then used to evaluate
and display the results of different arithmetic operations performed on those variables.
PROGRAM Arithmetic(OUTPUT);
{ Variable Declarations }
VAR
a, b :INTEGER;
{ Program Block }
BEGIN
a := 50;
b := 4;
WRITELN('a=',a);
WRITELN('b=',b);
WRITELN('a+b=',a+b);
WRITELN('a-b=',a-b);
WRITELN('a*b=',a*b);
WRITELN('a/b=',a/b);
WRITELN('a div b=',a DIV b); { used with integers only }
WRITELN('a mod b=',a MOD b) { used with integers only }
END.
ANSWER
To write output of the program:
a=50
17. b=4
a+b=54
a-b=46
a*b=200
a/b= 1.2500000000000000E+0001
a div b=12
a mod b=2
QUESTION 2
Write a program to calculate employee wages according to the formula: Wages :=HoursWorked
* PayRate; inputHoursWorked and PayRate from the keyboard and display Wages preceded by
the string ‘USD’.
ANSWER
PROGRAM Payroll(INPUT,OUTPUT);
VAR
HoursWorked, PayRate, Wages :REAL;
{ Program Block }
BEGIN
WRITE('Please enter hours worked: ');
READLN(HoursWorked);
WRITE('Please enter pay rate: ');
READLN(PayRate);
Wages :=HoursWorked * PayRate;
WRITELN;
WRITELN('Wages = $', Wages:0:2)
END.
QUESTION 3
Write the Pascal expressions for the following:
i. The quadratic equation: Ax2
+ Bx + C
ii. The determinant: B2 – 4AC
iii. The square root of the determinant
iv. The absolute value of the determinant
Then, write a program to produce the roots of the equation according to the input values
of A, B, and C. Use test values for A, B, and C that give real roots. Typical values
are:
A=1, B=2, C=1, give the solution: X1= X2= –1.00
A=1, B=4, C=2, give the solution: X1= –0.59, X2= –3.41
18. ANSWERS
i. A*SQR(X)+B*X+C
ii. SQR(B)-4*A*C
iii. SQRT((SQR(B)-4*A*C))
iv ABS(SQR(B)-4*A*C)
PROGRAM Quadratic(INPUT,OUTPUT);
VAR
D, X1, X2 :REAL;
A, B, C: INTEGER;
BEGIN
WRITE('Enter the values of A,B and C for the quadratic
equation:');
READLN(A,B,C);
{ Determinant}
D:=SQR(B)-4.0*A*C;
{ Roots }
X1:=(-B+SQRT(D))/(2*A);
X2:=(-B-SQRT(D))/(2*A);
WRITELN('X1=',X1:2:2,' X2=',X2:2:2);
WRITELN('Press ENTER to continue...');
READLN
END.
Sample runs:
A=1, B=2, C=1
X1=X2=-1.00
A=1, B=4, C=2
X1= -0.59
X2= -3.41
QUESTION 4
Modify the program you wrote in Qn3 to solve a quadratic equation (Ax² + Bx +C) for both real
and imaginary roots.
ANSWER
Modified Complete Solution of a Quadratic Equation will be:
PROGRAM Quadratic2(INPUT,OUTPUT);
VAR
A, B, C, D, X1, X2 :REAL;
BEGIN
WRITE('Enter the values of A,B,C separated by spaces:');
READLN(A,B,C);
{ Determinant}
D:=SQR(B)-4.0*A*C;
IF D < 0 THEN
BEGIN
WRITELN('Roots are imaginary.');
WRITELN('X1=',-B/(2*A):0:2,'+j',SQRT(ABS(D))/(2*A):0:2);
WRITELN('X2=',-B/(2*A):0:2,'-j',SQRT(ABS(D))/(2*A):0:2)
19. END
ELSE
BEGIN
WRITELN('Roots are real.');
WRITELN('X1=',(-B+SQRT(D))/(2*A):0:2);
WRITELN('X2=',(-B-SQRT(D))/(2*A):0:2)
END;
WRITELN('Press ENTER to continue ...');
READLN
END.
{ Sample runs:
Real roots:
A=2, B=4, C=1
X1=0.29
X2=1.70
Equal real roots:
A=1, B=2, C=1
X1=-1
X2=-1
Imaginary roots:
A=1, B=1,C=1
X1=-0.5+j0.87
X2=-0.5-j0.87
QUESTION 5
Write a program to describe the weather according to the following temperature classifications:
Temperature Classification
24 and greater Hot
10 to 23 Cool
0 to 9 Cold
less than 0 Freezing
ANSWER
PROGRAM WeatherTester(INPUT,OUTPUT);
VAR
Temperature :INTEGER;
Hot, Cool, Cold, Freezing :BOOLEAN;
BEGIN
WRITE('Please enter the temperature:');
READLN(Temperature);
Hot := (Temperature >= 24);
Cool := (Temperature >= 10) AND (Temperature < 24);
Cold := (Temperature >= 0) AND (Temperature < 10);
Freezing := (Temperature < 0);
WRITELN;
{ Beginning of the IF construct }
IF Hot THEN
WRITELN('IT‟S VERY HOT!!!')
ELSE IF Cool THEN
WRITELN('IT‟S COOL OUT THERE!!!!!.')
20. ELSE IF Cold THEN
WRITELN('Oh, it is cold. ')
ELSE IF Freezing THEN
WRITELN(' It is freezing.')
ELSE
WRITELN('Hey, It is below the normal temperature!');
{ End of the IF construct }
{ ----------------------- }
WRITELN('Press ENTER to continue..');
READLN
END.
QUESTION 6
The number 2 and its powers are very important numbers in the computer field. Some of the
numbers, such as 1024 bytes (equivalent to 1 KB) and 65,536 bytes (64 KB) are commonly used.
In the following program a FOR loop is used to display the powers of two, using the same logic
that was used to calculate the power in Example 2-2. The program output gives the power and the
number 2 raised to this power. The initial and final values of the counter are supplied by the user
during the execution. Thus, you can determine the range of numbers you would like to examine.
PROGRAM ForLoop(INPUT, OUTPUT);
VAR
Base, Power, Start, Final :INTEGER;
BEGIN
Base := 2;
WRITE('Enter starting exponent:');
READLN(Start);
WRITE('Enter ending exponent:');
READLN(Final);
WRITELN;
WRITELN('Number Power of two');
FOR Power := Start TO Final DO
BEGIN
WRITE(Power:3);
WRITELN(EXP(LN(Base)*Power):20:0)
END;
WRITELN;
WRITELN('Press ENTER to continue..');
READLN
END.
Modify the program to save the output of the program in file (instead of seeing the output in the
screen). Plot the data of the output file (using Matlab or Excel). Label your plot. Use exponent
value from 1 to 30.
21. ANSWER
The following is a sample run using exponent values from 1 to 30:
Enter starting exponent:1
Enter ending exponent:30
Number Power of two
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
11 2048
12 4096
13 8192
14 16384
15 32768
16 65536
17 131072
18 262144
19 524288
20 1048576
21 2097152
22 4194304
23 8388608
24 16777216
25 33554432
26 67108864
27 13417728
28 268435456
29 536870912
30 1073741824
Press ENTER to continue..
By using MatLab
22. QUESTION 7
Write down the output of the following program for a sample run of 10 elements
PROGRAM AverageProg3(INPUT,OUTPUT);
VAR
Average, Sum, Number :REAL;
Kounter :INTEGER;
BEGIN
Sum := 0;
Average := 0;
Number := 0;
Kounter := 0;
WHILE Number<>-1 DO
BEGIN
Kounter :=Kounter + 1;
Sum := Sum + Number;
WRITE('Enter element #',Kounter,' (or –1 to end): ');
READLN(Number)
END;
IF Kounter> 1 THEN
Average := Sum / (Kounter - 1);
WRITELN;
WRITELN('Sum of Numbers = ', Sum:0:2);
WRITELN('Average of Numbers = ', Average:0:2);
WRITELN;
WRITELN('Press ENTER to continue..');
READLN
END.
23. ANSWER
The following is a sample run of 10 elements:
Enter element #1 (or -1 to end): 1
Enter element #2 (or -1 to end): 2
Enter element #3 (or -1 to end): 3
Enter element #4 (or -1 to end): 4
Enter element #5 (or -1 to end): 5
Enter element #6 (or -1 to end): 6
Enter element #7 (or -1 to end): 7
Enter element #8 (or -1 to end): 8
Enter element #9 (or -1 to end): 9
Enter element #10 (or -1 to end): -1
Sum of the numbers =45.00
Average of Numbers = 5.00
Press ENTER to continue…
QUESTION 8
Write the output of the program below for the following sample run:
Enter score for class #1: 90.5
Enter score for class #2: 80.5
Enter score for class #3: 86.2
Enter score for class #4: 90.3
Enter score for class #5: 74.8
Enter score for class #6: 98.5
PROGRAM Scores2(INPUT,OUTPUT);
CONST
NumberOfClasses = 6;
Tab = ' '; { 9 spaces }
VAR
Score :ARRAY[1..NumberOfClasses] OF REAL;
Average, SumOfScores :REAL;
Index :INTEGER;
BEGIN
{ Read the scores array }
{ --------------------- }
FOR Index := 1 TO NumberOfClasses DO
BEGIN
WRITE('Enter score for class #', Index,': ');
READLN(Score[Index])
END;
{ Calculate the sum }
{ ----------------- }
SumOfScores := 0;
FOR Index := 1 TO NumberOfClasses DO
SumOfScores :=SumOfScores + Score[Index];
{ Calculate the average }
{ --------------------- }
Average :=SumOfScores / NumberOfClasses;
24. { Display Results }
{ --------------- }
WRITELN;
WRITELN(Tab,'CLASS #');
WRITE(' '); { 6 spaces }
FOR Index := 1 TO NumberOfClasses DO
WRITE(Index:7);
WRITELN;
WRITE(Tab);
FOR Index := 1 TO NumberOfClasses DO
WRITE('-------');
WRITELN;
WRITE('SCORES ');
FOR Index := 1 TO NumberOfClasses DO
WRITE(Score[Index]:7:2);
WRITELN;
WRITE(Tab);
FOR Index := 1 TO NumberOfClasses DO
WRITE('-------');
WRITELN;
WRITELN(Tab,'Sum of scores = ', SumOfScores:0:2);
WRITELN(Tab,'Average of scores = ', Average:0:2);
WRITELN;
WRITELN('Press ENTER to continue..');
READLN
END.
This is a sample run:
Enter score for class #1: 90.5
Enter score for class #2: 80.5
Enter score for class #3: 86.2
Enter score for class #4: 90.3
Enter score for class #5: 74.8
Enter score for class #6: 98.5
CLASS
1 2 3 4 5 6
------------------------------------------
SCORES 90.50 80.50 86.20 90.30 74.80 98.50
------------------------------------------
ANSWER
output of the program
Sum of scores = 520.80
Average of scores = 86.80
Press ENTER to continue…
25. QUESTION 9
Write a Pascal program to read and store the test scores of ten students, then display
the output as shown below:
Student # Score
-----------------------
1 90.00
2 88.00
3 91.00
4 78.00
5 75.00
6 65.00
7 70.00
8 67.00
9 80.00
10 95.00
-----------------------
Average score = 79.90
ANSWER
PROGRAM Scores4(INPUT,OUTPUT);
CONST
NumberOfStudents = 10;
Tab = ' '; { 18 spaces }
Dash = '-';
NumberOfDashes = 46;
VAR
Score :ARRAY[1..NumberOfStudents] OF REAL;
Average, SumOfScores :REAL;
Index :INTEGER;
BEGIN
{ Read the scores array }
{ --------------------- }
FOR Index := 1 TO NumberOfStudents DO
BEGIN
WRITE('Enter Score of Student #', Index,': ');
READLN(Score[Index])
END;
{ Calculate the average score }
{ --------------------------- }
SumOfScores := 0;
FOR Index := 1 TO NumberOfStudents DO
SumOfScores :=SumOfScores + Score[Index];
Average :=SumOfScores / NumberOfStudents;
{ Display Results }
{ --------------- }
WRITELN;
WRITE(Tab, 'Student #');
WRITE(Tab, 'Score');
WRITELN;
WRITE(Tab);
FOR Index := 1 TO NumberOfDashes DO
26. WRITE(Dash);
WRITELN;
FOR Index := 1 TO NumberOfStudents DO
WRITELN(Tab,Index:3,tab,Score[Index]:10:2);
WRITE(Tab);
FOR Index := 1 TO NumberOfDashes DO
WRITE(Dash);
WRITELN;
WRITELN(Tab,'Average score = ', Average:0:2);
WRITELN;
WRITELN('Press ENTER to continue..');
READLN
END.
QUESTION 10
Write the output of the program below for the following sample run:
Enter element #1: 44
Enter element #2: 22
Enter element #3: 8
Enter element #4: 1
Enter element #5: 667
Enter element #6: 3
PROGRAM Sorting(INPUT,OUTPUT);
CONST
ArraySize = 6;
TYPE
Range = 1..ArraySize;
NumbersArray = ARRAY[Range] OF INTEGER;
VAR
Numbers :NumbersArray;
{ ----------------- Read procedure --------------- }
PROCEDURE ReadNumbers(L: INTEGER; VAR R :NumbersArray);
VAR
I :INTEGER;
BEGIN
FOR I := 1 TO L DO
BEGIN
WRITE('Enter element #', I,': ');
READLN(R[I])
END
END;
{ ----------------- Sort procedure --------------- }
PROCEDURE SortNumbers(M: INTEGER; VAR S :NumbersArray);
VAR
I, J, Pot :INTEGER;
BEGIN
FOR I := 1 TO M-1 DO
FOR J := I+1 TO M DO
IF S[I] > S[J] THEN
BEGIN { Swap contents }
27. Pot := S[J];
S[J] := S[I];
S[I] := Pot
END
END;
{ ---------------- Print procedure --------------- }
PROCEDURE PrintNumbers(N: INTEGER; T :NumbersArray);
VAR
I :INTEGER;
BEGIN
WRITELN;
WRITE('The sorted array is: ');
FOR I := 1 TO N DO
WRITE(T[I],' ');
WRITELN;
END;
{ --------------- Main Program ------------------- }
BEGIN
ReadNumbers(ArraySize, Numbers);
SortNumbers(ArraySize, Numbers);
PrintNumbers(ArraySize, Numbers);
WRITELN('Press ENTER to continue..');
READLN
END.
ANSWER
Sample run:
Enter element #1: 44
Enter element #2: 22
Enter element #3: 8
Enter element #4: 1
Enter element #5: 667
Enter element #6: 3
Output of the program
The sorted array is: 1 38 22 44 667
Press ENTER to continue