Question: Accept 7 digit number from the user. Write C program that checks (i) whether the number is divisible by 3 (ii) whether the number is
Accept 7 digit number from the user. Write C program that checks (i) whether the number is divisible by 3 (ii) whether the number is divisible by four. For example: if the input is 1234533, then divisible by 3. if it is 1234536, then divisible by 4. You must discover two logic to solve this problem, of which, write C code for one logic and write the other logic in this sheet. (i) (6 marks) Logic (ii) (4 marks) C program
Consider an array of size 10 which is filled with values from the range [0..10]. Write C-program that prints the multiplicities (the number of times it appears in the array) of each number. Is it possible to get multiplicities without using looping statements. If so, write the logic (no need to write c-code for this logic). If not possible, justify the impossibility.
. Consider an array of size 10 which is filled with distinct values from the range [0..10] (no value is used more than once). Since array size is 10 and there are 11 values (0 to 10), one value from the range is missing in the array. Write C program to identify the missing value from [0..10]. Also, write program to identify the missing value using just sequence statements. Note that the logic you come up with must be scalable, i.e., it must work for any array size. Suppose, we modify the question slightly and allow exactly one value from the range [0..10] to appear twice and all other values appear at most once. This means, two values from the range [0..10] are missing. Write C program to identify the two missing ones.
Accept from the user an integer r. Consider the equation x + y + z = r. How many non-negative integer solutions are there satisfying this equation. List all of them. For example, if r = 2, the possible solutions are (2, 0, 0),(1, 1, 0),(0, 1, 1), ... and so on. Further, (i) compute all solutions with the additional constraint x 0, y 2, z 1. (ii) Is it possible to get the number of solutions (just the count) using sequence statements.
How many pairs (a, b) are there in the range [1..30] which are relatively prime (co prime). I.e., GCD(a,b) is 1. Your program must be scalable, i.e., it must work if the range is [1..r] instead of [1..30]. List all pairs in the range [1..30]. Is there a pair in the above listing whose linear combination gives every integer starting from 10 until 30. For example, (2, 3) are relatively prime, and the integer 11 = 42+13, 12 = 6 2 + 0 3. In general, x = m a + n b and m, n are non-negative integers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
