Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 8E
Explanation of Solution
The following program will round off the value to the next largest even multiple of another value:
//include the header file
#include <stdio.h>
//definition of main method
int main (void)
{
//declare the variables
int i, j, ans;
//get the inputs from the user
printf("Enter the value to round off: ");
scanf("%d", &i);
printf ("Enter the value to make i divisible of...
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
let n = 1*3*5*....*197*199 (the product of first 100 odd numbers)
find the last 2 digits of n
Suppose n is a positive integer.
Please calculate the multiplication series of 8 matrices: A*B*C*D*E*F*G*H
The dimensions are: 32x35, 35x24, 24x30, 30x36, 36x25, 25x40, 40x34, 34x35
What is the best order to multiply them? Please use parentheses to express the multiplication order, such as (((AB)(CD))((EF)(GH)))
How many multiplications are required in total?
Knowledge Booster
Similar questions
- ii. find the value of N so that y less than 0.00000075.arrow_forwardMathematics is a very crucial subject in our life. It gives a power to calculate the daily things. Rajesh is the one of the brightest student in this subject so he has an integer N. His task is to break N into some number of (integer) powers of 2. TO achieve this, he can perform the following operation several times (possibly, zero): Choose an integer X which he already has, and break X into 2 integer parts (Y and Z) such that X = Y + Z. Find the minimum number of operations required by Rajesh to accomplish his task using Python Language. Input 1 3 Output 1arrow_forwardWrite an algorithm that asks the user to enter a positive integer n and prints the sum of the divisors of n.arrow_forward
- example of program that calculate the following sum: n k 14. Give an ΣΣ i=0 j=0arrow_forwardDescription Xiao Zhang is often distressed because there are too many things to arrange. Now he has n tasks at hand, and each task has a starting times, and an ending time e;. To complete a task, he must do it from the starting time to the ending time, and Xiao Zhang can only perform one task at the same time. Xiao Zhang wants to know how many tasks he can accomplish at most. Input The first line is an integer n (1sns300000), indicating the number of tasks Xiao Zhang has at hand. In the next n lines, each line contains two integers s₁, e¡ (1≤s;arrow_forwardPython problem: Replace of the ten Xs in the simple sum shown below with a digit drawn without-replacement from the set of 10 digits [ 1,1,2,2,4,4,7,7,8,9 ] (the duplicates are intended) so that the sum is correct. Each digit is used exactly one time in each candidate replacement. X5XX + XXX3 = XX6XX Note There are 10! = 3,628,800 candidate permutations to check and 96 of the candidate permutations qualify as solutions. Of those 96 solutions, only 96 ÷ (2!×2!×2!×2!) = 6 are unique soultions. Sample Output: 4524 + 8173 = 12697 4574 + 8123 = 12697 8524 + 4173 = 12697 8524 + 9123 = 17647 8574 + 4123 = 12697 9524 + 8123 = 17647arrow_forwardSuppose you are given an array whose first n – f(n) elements are sorted, but whose last f(n) are not. How would you sort the entire array in O(n) time if f(n) is defined as follows? Be specific with your answer.arrow_forwardWhat is the minimum number of multiplications needed to generate x60 when starting from x? (you may only use terms of x to solve this problem, x * x = x2 is one multiplication, x2 * x2 leaves us at 2 multiplications, …)arrow_forwardThe following function f uses recursion: def f(n): if n <= 1 return n else return f(n-1) + f(n-2) 5 Let n be a valid input, i.e., a natural number. Which of the following functions returns the same result but without recursion? a) def f(n): a <- 0 b <- 1 if n = 0 return a elsif n = 1 return b else for i in 1..n c <- a + b a <- b b <- c return b f(n): a <- 0 i <- n while i > 0 a <- a + i + (i-1) return a f(n): arr[0] <- 0 arr[1] <- 1 if n <= 1 return arr[n] else for i in 2..n arr[i] <- arr[i-1] + arr[i-2] return arr[n] f(n): arr[0..n] <- [0, ..., n] if n <= 1 return arr[n] else a <- 0 for i in 0..n a <- a + arr[i] return aarrow_forward2. How many even 4-digit numbers greater than 3000 can be formed from the digits 2, 6, 7, 8, 9 if no digit can be used more than once?arrow_forwardWrite a program that computes the following: sigma summation i=0 to N (i^3 +2N)arrow_forwardThe following function f uses recursion:def f(n):if n <= 1return nelse return f(n-1) + f(n-2)Let n be a valid input, i.e., a natural number. Which of the following functions returns the same result but without recursion?a) def f(n):a <- 0b <- 1 if n = 0return aelsif n = 1 return belsefor i in 1..nc <- a + b a <- b b <- c return bb) def f(n):a <- 0i <- n while i > 0 a <- a + i + (i-1) return ac) def f(n): arr[0] <- 0 arr[1] <- 1 if n <= 1return arr[n]elsefor i in 2..n arr[i] <- arr[i-1] + arr[i-2]return arr[n]d) def f(n): arr[0..n] <- [0, ..., n] if n <= 1return arr[n]elsea <- 0 for i in 0..n a <- a + arr[i]return aarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT