Concept explainers
If you take the value of N as computed in exercise 2, subtract 621,049 from it, and then take that result modulo 7, you get a number from 0 to 6 that represents the day of the week (Sunday through Saturday, respectively) on which the particular day falls. For example, the value of N computed for August 8, 2004, is 732.239 as derived previously. 732,239 – 621,049 gives 111,190. and 111,190 % 7 gives 2, indicating that this date falls on a Tuesday.
Use the functions developed in the previous exercise to develop a
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Programming in C
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Absolute Java (6th Edition)
Java How To Program (Early Objects)
Starting Out with Python (3rd Edition)
Computer Science: An Overview (12th Edition)
- For each number n from 1 to 4, compute n2 mod 5. Then for each n, compute n3 mod 5 and finally n4 mod 5. Do you notice anything surprising? (You may need to go past n = 4 to see a pattern)arrow_forwardWorking with cell addresses The address of a cell in Google sheets can be specified in two ways: either as a letter-number pair like C5, or as a pair of numbers like "row 5, column 3". Some formulas may be easier to specify on one way or the other, so it's useful to know how to convert from one form to the other and back. ROW() and COLUMN() take addresses in A1 format and return the number of the row and column respectively. ADDRESS() takes numeric row and column inputs and returns the address in A1 format. It also has an option argument to specify the relativity of the addresses: 1 (the default) returns absolute addresses; 2, 3, and 4 return row absolute, column absolute, and relative addresses respectively. In this chapter you'll be working with Indian butterfly data from Singh and Pandey. Instructions In column H, get the row numbers of the Locality column. In column I, get the column numbers of that column. In column J, convert columns H and I back to addresses in $A$1…arrow_forwardYou need to take a trip by car to another town that you have never visited before. Therefore, you are studying a map to determine the shortest route to your destination. Depending on which route you choose, there are five other towns (call them A, B, C, D, E) that you might pass through on the way. The map shows the mileage along each road that directly connects two towns without any intervening towns. These numbers are summarized in the following table, where a dash indicates that there is no road directly connecting these two towns without going through any other towns. Miles between Adjacent Towns Town A B C DE Destination Origin A 40 60 50 10 70 B 20 55 40 50 10 D 60 E 80 (a) Formulate this problem as a shortest-path problem by drawing a network where nodes represent towns, links represent roads, and numbers indicate the length of each link in miles. (b) Use the Dijkstra's algorithm to solve this shortest path problem.arrow_forward
- You need to take a trip by car to another town that you have never visited before. Therefore, you are studying a map to determine the shortest route to your destination. Depending on which route you choose, there are five other towns (call them A, B, C, D, E) that you might pass through on the way. The map shows the mileage along each road that directly connects two towns without any intervening towns. These numbers are summarized in the following table, where a dash indicates that there is no road directly connecting these two towns without going through any other towns. Town Origin A B C D E A 40 Miles between Adjacent Towns C D E B 60 10 50 20 - 70 55 - 88811 40 50 10 Destination | | || 88 60 80 (a) Formulate this problem as a shortest-path problem by drawing a network where nodes represent towns, links represent roads, and numbers indicate the length of each link in miles. (b) Use the Dijkstra's algorithm to solve this shortest path problem. Illustrate your work by using a table.…arrow_forwardQ4/Full the following blanks (1101 1010)BCD(5211) = ( )BCD(3321)=()EX-3=()16 * (1101 1010)BCD(5211) = (1110 1100)BCD(3321)=(1010110)EX-3= (A6)16 (1101 1010)BCD(5211) = (1110 0111)BCD(3321)=(1011001)EX-3= (56)16 (1101 1010)BCD(5211) = (1101 0111)BCD(3321)=(1011001)EX-3= (2B)16 (1101 1010)BCD(5211) = (1011 1110)BCD(3321)=(1000111)EX-3= (44)16 None of them IIarrow_forwardThe greatest common divisor of two positive integers, A and B, is the largest number that can be evenly divided into both of them. Euclid's algorithm can be used to find the greatest common divisor (GCD) of two positive integers. You can use this algorithm in the following manner: 1. Compute the remainder of dividing the larger number by the smaller number. 2. Replace the larger number with the smaller number and the smaller number with the remainder. 3. Repeat this process until the smaller number is zero. The larger number at this point is the GCD of A and B. Write a program that lets the user enter two integers and then prints each step in the process of using the Euclidean algorithm to find their GCD. An example of the program input and output is shown below: Enter the smaller number: 5 Enter the larger number: 15 The greatest common divisor is 5arrow_forward
- Correct answer will be upvoted else downvoted. number is called 2050-number if it is 2050, 20500, ..., (2050⋅10k for integer k≥0). Given a number n, you are asked to represent n as the sum of some (not necessarily distinct) 2050-numbers. Compute the minimum number of 2050-numbers required for that. Input The first line contains a single integer T (1≤T≤1000) denoting the number of test cases. The only line of each test case contains a single integer n (1≤n≤1018) denoting the number to be represented. Output For each test case, output the minimum number of 2050-numbers in one line. If n cannot be represented as the sum of 2050-numbers, output −1 instead.arrow_forwardHere is the assignment Write a program that prints the multiplication table but inserts a randomly generated incorrect value between 1 and 50 into a cell whose row and column are randomly selected. Make sure the program does insert an incorrect value. For example, if row and column of 3 and 4 are randomly selected, keep generating a random number to print for that location until it's not the right value of 12. Then, ask the user to tell where in the table the incorrect number is located by entering the row and column of the incorrect number. Print whether the user was right or not. If he or she was right, ask for and read the correct value; if not, the program must give the correct location and the correct number. My main issue: is how to set up the multiplication table? I've only learned the basics in C++ (loops and if statements).arrow_forwardOn the planet Tatooine, droids do computations in base-6. What is the greatest base-6 number with three different digits? (Your base-6 number must have a separate digit for each digit.) Make a decimal out of your answer (base-10).arrow_forward
- please read the question carefully and answer the question carefullyarrow_forwardThere are a set of courses, each of them requiring a set of disjoint time intervals. For example, a course could require the time from 9am to 11am and 2pm to 3pm and 4pm to 5pm. You want to know, given a number K, if it’s possible to take at least K courses. You can only take one course at any single point in time (i.e. any two courses you choose can’t overlap). Show that the problem is NP-complete, which means that choosing courses is indeed a difficult thing in our life. Use a reduction from the Independent set problem.arrow_forward1.Given a positive integer, N, the ’3N+1’ sequence starting from N is defined as follows:If N is an even number, then divide N by two to get a new value for NIf N is an odd number, then multiply N by 3 and add 1 to get a new value for N.Continue to generate numbers in this way until N becomes equal to 1For example, starting from N = 3 the complete ’3N+1’ sequence would be:3, 10, 5, 16, 8, 4, 2, 1Write c++ code to ask the user to enter a positive integer (N) in the main() function. Write a function sequence()that receives the integer value N and display the ‘3N+1’ sequence starting from the integer value that wasreceived (entered by the user). The function must also count and return the numbers that the sequenceconsists of. The returned value must be displayed from the main() function.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr