CPR workshop4
.docx
keyboard_arrow_up
School
Seneca College *
*We aren’t endorsed by this school
Course
144
Subject
Computer Science
Date
Feb 20, 2024
Type
docx
Pages
3
Uploaded by CorporalComputerNightingale26
Number Systems Activity
Computer Principles for Programmers
Abhijeet Singh
144374220 asingh1289
@mySeneca.ca
Click or tap here to enter text.
There are many notes in the instructions to help you earn marks for the questions below.
Exercise One of Two
–
integer overflow
(80 points)
1)
(7.5 points) ) If a variable counting seconds is stored in a signed long
32-bit integer, how many days
will it take until that integer overflows? (to one decimal place)
248.55 days until it over flows 2)
(15 points) Convert the maximum value of an unsigned long
32-bit integer, representing hundredths of a second, into whole numbers of
days : hours : minutes : seconds . hundredths of a second. After n
days, how many hours remain? After n
hours, how many minutes remain? etc.
497 2
27
52
95
DAYS
HOURS : MINUTES :
SECONDS
.
HUNDREDTH
S
3)
(2.5 points) What are the maximum and minimum values that can be stored in a short
16-bit signed integer?
16-bit signed integer maximum =32767
… minimum = -32768
4)
(5+5 points) Give examples of two short
16-bit
signed integers that when added together would cause overflow. 16386 + 16386 are two positive values causing overflow when added together. -16500 + -16501 are two negative values causing overflow when added together. Binary Search Bug
5)
(10 points) What is potentially wrong with the (low + high) / 2 calculation to find the
middle point? Under what conditions would the calculation go wrong?
It may lead to an overflow
because high and low can exceed range after adding up and will eventually lead to overflow as it is greater than the maximum value.
SUMMER 2023
1 of 3
Number Systems Activity
Computer Principles for Programmers
6)
(10 points) REWRITE the
mid
calculation to prevent overflow
from
mid = (low + high) / 2;
to
mid =
low +(high-low)/2;
;
7)
(25 points)
Write a 250+ word “reflection”(similar to a workshop in your programming class) describing the steps you used to develop and test your solution to the calculation bug. There are many steps that are used by me when I develop and test the solution to the calculation bug. I have learned that this requires a systematic approach, so I implemented few steps which are given below. The first step is to find out the problem or error and solve the issue. In my solution the bug was the wrong answer generated because of the overflow of the integers during calculating the middle point. I then tried to figure out a way to get rid of the error or the bug by doing several researches. I even took some advice from one of my senior, who told me that the problem was overflow of the integers. To keep the answer within a limited and valid range, I applied the formula, mid = low + (high – low) / 2. After that, I implemented the code
by using the correct syntax and variables so that there are no further errors to encounter. The next step after executing the test was to look for any more bug or error, if there was any I rectified them by using debug and double checking my code. Furthermore, I even evaluated its performance and effiency. I recorded the whole developing and testing process. I was able to enhance my knowledge about problem solving. By following these few steps, I developed a correct solution and even tested my solution. This systematic process has always allowed me to
learn about the problem solving, developing and testing the solution.
Exercise Two of Two
–
Numbering Systems and Conversions
(20 points)
8)
(10 points ) What is the hex value for these colours?
Red
decimal
Green
decimal
Blue
decimal
Hex triplet
Colour
Description
15
245
231
#0FF5E7
TEAL
192
255
238
#C0FFEE
LIGHT GREEN
208
13
30
#D00D1E
RED
186
187
30
#BABBE
DARK YELLOW
126
164
112
#7EA470
GREEN
SUMMER 2023
2 of 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
MATLAB CODE please in computer
arrow_forward
variable1 DWORD 14253647h
Assuming that the computer uses little endian order, illustrate how 'variable1' is
stored in the memory.
Answer format: For the following example,
variable1 D WORD 14253647h
If you think 14 goes to 0-th byte and 25 goes to 1st byte, you can write answer as
follows:
Offset (i-th byte) : value
0:14
1:25
Paragraph
B
III
arrow_forward
Homework-1-Q 2021.pdf
4 من 5
Al-Farabi University College
Computer Programming Methodology
Department of Computer Engineering
Dr. Hussein Muzahim Aziz Basi
ylallt
First Year
2020-2021
AL-FA RABI
UNIVERS TY COLLIG
Homework 3:
Write a program to calculate two real numbers. The operation you are going to used are "add,
subtract, multiple and division" and it is going to be optional to calculate the two numbers
separately at each time you are going to execute the program,
After you execute the program separately at each time your run the program the output look like
below:
• to add betveen tuo nunbers
- to subtract bet veen tuo nunhers
* to nultiply betveen tuo nunbera
- to diu ide hetveen tuo nunbers
Enter
Enter
Enter
Enter
Enter the operation i+
Enter the Ist nunher :2.3
Enter the 2nd nunber :5.6
The result is 7.980
Press any ke y to continue
. • --
OR
Enter
Enter
Enter
Enter
to add betveen tuo nunbers
- to subtract betueen tuo nunbers
- to nultiply betueen tuo nunbere
to divide betueen…
arrow_forward
Menus The local diner offers a meal combination consisting of an appetizer, a soup, a main course, and a dessert. There are four appetizers, five soups, three main courses, and four desserts. Your diet restricts you to choosing between a dessert and an appetizer. (You cannot have both.) Given this restriction, how many three-course meals are possible?
A computer byte consists of eight bits, each bit being either a 0 or a 1. Assume that characters are represented using a code that uses a byte for each character.
Some written languages, such as Chinese and Japanese, use tens of thousands of different characters. If a language uses roughly 97,000 characters, a computer code for this language would have to use how many bytes per character?
arrow_forward
Evaluate the following postfix expressions:
65 78 + 87 - 45 * ++
95 +36
+97 - 1
952 + -3 *
(i)
(ii)
(iii)
arrow_forward
SOLVE IN C#
Canada Government has announced 250 immigration visa lottery for third world countries. Total number of Application collected 10000, starting from application number 1 to 10000. You are required to write a program for Canadian government to select 250 visa for lottery visa, randomly from the pool of 10000 application and print the application number on screen
Note: No input required in this program
arrow_forward
UNIVERS
UNIVER GE
AL-FARABI
UNIVERSITY COLL GE
Homework 3:
Write a program to calculate two real numbers. The operation you are going to used are "add,
subtract, multiple and division" and it is going to be optional to calculate the two numbers
separately at each time you are going to execute the program.
After you execute the program separately at each time your run the program the output look like
below:
Enter
Enter
+ to add between two nunbers
- to subtract betveen tuo nunbers
to nultiply between tvo nunbers
to divide betueen tuo nunbers
Enter
Enter
Enter the o peration :+
Enter the ist nunber :2.3
Enter the 2nd nunber :5.6
The result is 7.980
Press any key to continue. . .-
OR
to add betueen two nunbers
to subtract between two nunbers
* to nultiply betveen two nunbers
/ to divide between two nunbers
Enter
Enter
Enter
Enter
Enter the operation :-
Enter the 1st nunber :2.3
Enter the 2nd nunber :5.6
The result is -3.300
Press any key to continue
...-
Al-Farabi University College…
arrow_forward
Please help
arrow_forward
docs.google.com/forms
YA
Q5: Write relational expressions to
express the following conditions
(using variable names of your
:choosing)
A person's identification (1
3 نقاط
number is less than 500 and the
person is older than 55
إجابتك
bläi 3
The current day is the 15th (2
.day of the 1st month
إجابتك
3 نقاط
.The letter input is m
إجابتك
7
صفحة 6
من
arrow_forward
| ZVY O
= السؤال
In C++ variable type char its size is:
Three Bytes
Two bytes
One byte
Non of them.
حفظ الاجابة
arrow_forward
n22" operations is better than n! operations. (! = means factorial)
O False
O True
arrow_forward
In C language please
arrow_forward
Questions:
Computer-Assisted Instruction) The use of computers in education is referred to as computer- assisted instruction (CAI). Write a program that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as
How much is 6 times 7?
The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the application begins execution and each time the user answers the question correctly.
PLEASE IN C++ LANGUAGE
arrow_forward
Q5: In C programming, "Char" and "int" data types are used. They represent certain number
of bits. Please fill in the blanks for following data types assuming that that the code is running
on 32 bit machine.
Data type
Total number of bits/bytes
int
char
arrow_forward
Allowed language: C language The output should be the same with example and please code correctly.please do not copy from other questions
arrow_forward
CODE FOR SINGLE-DIGIT CALCULATOR USING EMU8086
Write a program that would accept 2 single-digit numbers num1 and num2 (0-9) and an arithmetic operator (+, - , * and /). Perform arithmetic operations entered with num1 and num2. If the operator is invalid, display "Operation Error".
arrow_forward
A short value is stored in 16 bits. Write a program that prompts the user to enter a short integer and displays the 16 bits for the integer.
arrow_forward
Q/use visual Basic to write
a Program to compute the
Functions: Natural logarithms.
integer values and absolute
Value for x value
x = y² - 3y + 2
arrow_forward
< in C language means:
One's complement
O Logical OR
O Logical shift right
O Inequality
O Logical AND
O Two's complement
O Exclusive OR
O Equability
O Logical shift left
arrow_forward
Stream manipulator showpoint forces floating-point values to print with the default sixdigits of precision unless the precision value has been changed, in which case floatingpoint values print with the specified precision. T/F
arrow_forward
Write pseudocode with variables!!
Write all declare variables first then initiate
pseudocode
arrow_forward
#include
#include "userdefined"
#include [userdefined]
نقطتان )2(
It is guaranteed that a
has at least 8 bits and a
.has at least 16 bits
int, float
char, int
bool, char
char, short
7
صفحة 5
التالي
رجوع
عدم إرسال كلمات المرور عبر نماذج Go ogle مطلقا.
تم إنشاء هذا النموذج داخل University. of Basrahالإبلاغ عن
إساءة الاستخدام
Google zilaj
arrow_forward
Write pseudocode with variables and comments!!
Write all declare variables first then initiate
pseudocode
arrow_forward
Copy paste answer from other websites will be downloaded directly
Correct and detailed answer will be Upvoted
arrow_forward
IN C LANGUAGE
Prompt the user to enter no of rows and columns and print ASCII characters in the following sequence/shape:
Expected Output
Enter no of rows: 5
Enter no of columns: 5
Result:
ABCDE
F G
H I
J K
LMNOP
arrow_forward
X=4,y=5,z=6
2. [102%7 = 10] or [x*y == y*z]
arrow_forward
ewqeqeqwe
python please
arrow_forward
Assembly language 32 bit MASM IrvineYou are to ask the user for a number from 5 - 20.
You will then do the Fibonacci sequence up to that number.
You may need to research the Fibonacci sequence first.
Example:
Please enter a number from 5 - 20: 10
0, 1, 1, 2, 3, 5, 8, 13, 21, 34
Note, the user typed 10, so it shows the first 10 numbers of the sequence.
The initial numbers the computer should start with are the 0 and the 1 at the start. Please add a **Loop** in the program
arrow_forward
AC that adds two very large integers entered by the user on the keyboard
write the program. Very large integers represent standard data types (long int, double, etc.)
you cannot collect it using. Reading and adding numbers from the keyboard as a string
As you learned the process in elementary school, starting from the units digit, you can add
the mutual numbers one by one.
you must realize by collecting. The numbers that the user has entered into a different
number of digits.
In order to have it, your program should work. The output of your program is the example
below
should be compatible with the program outputs. In the program output, as in the addition
operation
the numbers and the total should be written one under the other, with the mutual digits
aligned.
Sample program output - 1:
First number: 111111111111111111111111
Second number: 999999999
11111111111u111.
9999999999
1111111111111120000000000
Sample program output - 2:
First number: 11
Second number:…
arrow_forward
Create a main() function for your program. The purpose of this function is to control the
game logic for a Power Quiz game. The steps of this game are as follows:
Set the user's score to 0.
●
Generate a random integer n in the range [1,128] inclusive.
Ask the user to enter the corresponding binary number for n.
Use your binary_to_decimal() function to find the correct answer.
Check if the user's answer is correct or not
O If correct, add 1 to their current score
O
If not, tell them the correct answer.
Repeat these steps until the user types "stop" in place of a number.
If the user types "stop", your program should print out their final score and terminate the
game.
Finally, add the following code to the end of your program to make main() function
work. Note those '' are two underscores '__'.
if name
main()
Print
==
11
'___main__":
Activity Details
arrow_forward
lb. Floating point addition/subtraction
Take the last 5 digits of your student number (example, A,A‚A‚A,A, in 2021-4,4‚A‚A„A,) and
divide it by 4, taking note of the remainder. The value of the remainder will determine which set
below is assigned to you.
The given values below are written in 32-bit Single-precision Floating-point number
representation (IEEE-754) in normalized form. Perform the floating-point operation assigned to
you. Express the final answers in IEEE-754. Show your complete solution. Make sure to perform
the arithmetic in binary (i.e. not in decimal, but you can do this to double-check your answer).
Only solutions that show the binary arithmetic will be given full marks. (Please write down which
set is assigned to you above your solution/answer)
Given values:
A: 11000000010110100101010000000000
B: 11000001110110111010000000000000
C: 01000001100111001000101010000000
D: 01000000010010011000100101000000
Set I (Remainder = 0): A+C
Set III (Remainder= 2): B + C
Set II…
arrow_forward
0199%
10:00
docs.google.com/forms
13
last
constant
Problem 1
At a certain university, students have to submit their exams online. The administration decides that for each
minute of late submission, 5 points are deducted. Write a program that asks the user for his initial grade and
how long he delayed in submitting, and then displays the final result.
Sample Run 1:
Enter your initial grade: 82
Enter the late submission time (in minutes) : 6
Your final grade is 52
Sample Run 2:
Enter your initial grade: 115
Grades should be between 0 and 100
Sample Run 3:
Enter your initial grade: 43
Enter the late submission time (in minutes): 10
Your final grade is 0
Sample Run 4:
Enter your initial grade: 72
Enter the late submission time (in minutes) : -2
Time should be positive
Your answer
Problem 2
Write a Java program
integers day. month, and vear. You are NOT required to check if the values entered by the user are in
give the user the ability to determine the day of a given date. The user shall…
arrow_forward
Please write codes for the below equation
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Related Questions
- MATLAB CODE please in computerarrow_forwardvariable1 DWORD 14253647h Assuming that the computer uses little endian order, illustrate how 'variable1' is stored in the memory. Answer format: For the following example, variable1 D WORD 14253647h If you think 14 goes to 0-th byte and 25 goes to 1st byte, you can write answer as follows: Offset (i-th byte) : value 0:14 1:25 Paragraph B IIIarrow_forwardHomework-1-Q 2021.pdf 4 من 5 Al-Farabi University College Computer Programming Methodology Department of Computer Engineering Dr. Hussein Muzahim Aziz Basi ylallt First Year 2020-2021 AL-FA RABI UNIVERS TY COLLIG Homework 3: Write a program to calculate two real numbers. The operation you are going to used are "add, subtract, multiple and division" and it is going to be optional to calculate the two numbers separately at each time you are going to execute the program, After you execute the program separately at each time your run the program the output look like below: • to add betveen tuo nunbers - to subtract bet veen tuo nunhers * to nultiply betveen tuo nunbera - to diu ide hetveen tuo nunbers Enter Enter Enter Enter Enter the operation i+ Enter the Ist nunher :2.3 Enter the 2nd nunber :5.6 The result is 7.980 Press any ke y to continue . • -- OR Enter Enter Enter Enter to add betveen tuo nunbers - to subtract betueen tuo nunbers - to nultiply betueen tuo nunbere to divide betueen…arrow_forward
- Menus The local diner offers a meal combination consisting of an appetizer, a soup, a main course, and a dessert. There are four appetizers, five soups, three main courses, and four desserts. Your diet restricts you to choosing between a dessert and an appetizer. (You cannot have both.) Given this restriction, how many three-course meals are possible? A computer byte consists of eight bits, each bit being either a 0 or a 1. Assume that characters are represented using a code that uses a byte for each character. Some written languages, such as Chinese and Japanese, use tens of thousands of different characters. If a language uses roughly 97,000 characters, a computer code for this language would have to use how many bytes per character?arrow_forwardEvaluate the following postfix expressions: 65 78 + 87 - 45 * ++ 95 +36 +97 - 1 952 + -3 * (i) (ii) (iii)arrow_forwardSOLVE IN C# Canada Government has announced 250 immigration visa lottery for third world countries. Total number of Application collected 10000, starting from application number 1 to 10000. You are required to write a program for Canadian government to select 250 visa for lottery visa, randomly from the pool of 10000 application and print the application number on screen Note: No input required in this programarrow_forward
- UNIVERS UNIVER GE AL-FARABI UNIVERSITY COLL GE Homework 3: Write a program to calculate two real numbers. The operation you are going to used are "add, subtract, multiple and division" and it is going to be optional to calculate the two numbers separately at each time you are going to execute the program. After you execute the program separately at each time your run the program the output look like below: Enter Enter + to add between two nunbers - to subtract betveen tuo nunbers to nultiply between tvo nunbers to divide betueen tuo nunbers Enter Enter Enter the o peration :+ Enter the ist nunber :2.3 Enter the 2nd nunber :5.6 The result is 7.980 Press any key to continue. . .- OR to add betueen two nunbers to subtract between two nunbers * to nultiply betveen two nunbers / to divide between two nunbers Enter Enter Enter Enter Enter the operation :- Enter the 1st nunber :2.3 Enter the 2nd nunber :5.6 The result is -3.300 Press any key to continue ...- Al-Farabi University College…arrow_forwardPlease helparrow_forwarddocs.google.com/forms YA Q5: Write relational expressions to express the following conditions (using variable names of your :choosing) A person's identification (1 3 نقاط number is less than 500 and the person is older than 55 إجابتك bläi 3 The current day is the 15th (2 .day of the 1st month إجابتك 3 نقاط .The letter input is m إجابتك 7 صفحة 6 منarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr