Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8
1.
Write a C program to compute the sum of the two input
values. If the two values are the same, then return triple their sum. Expected Output: 3 12 Click me to see the solution
2. Write a C program that will take a number as input and find
the absolute difference between the input number and 51. If the input number is greater than 51, it will return triple the absolute difference. Expected Output: 6 21 0 Click me to see the solution
3. Write a C program that checks two given integers and returns
true if at least one of them is 30 or if their sum is 30. In other words, if either of the two integers is 30 or if their sum equals 30, the program will return true. Expected Output: 1 1 0 Click me to see the solution
4. Write a C program to check a given integer and return true if
it is within 10 of 100 or 200. Expected Output: 1 1 0 Click me to see the solution 5. Write a C program that checks if a positive integer is divisible by either 3 or 7, or both. If the integer is a multiple of 3, then the program will return true. Similarly, if the integer is a multiple of 7, then also the program will return true. If the integer is not a multiple of 3 or 7, then the program will return false. Expected Output: 1 1 1 0 Click me to see the solution
6. Write a C program that checks two given temperatures and
returns true if one temperature is less than 0 and the other is greater than 100, otherwise it returns false. Expected Output: 1 1 0 Click me to see the solution
7. Write a C program to check two given
integers whether either of them is in the range 100..200 inclusive. Expected Output: 1 0 1 Click me to see the solution
8. Write a C program that checks if three given integers are in
the range of 20 to 50 (inclusive) and returns true if at least one of them is within the range. If none of the integers are within the range, the program returns false. Expected Output: 1 1 1 0 Click me to see the solution
CAN BE REDONE WITH BOOLEANS
9. Write a C program that checks if three given integers are in
the range of 20 to 50 (inclusive) and returns true if at least one of them is within the range. If none of the integers are within the range, the program returns false. Expected Output: 1 1 1 0 Click me to see the solution
10. Write a C program to check which number is nearest to the
value 100 among two given integers. Return 0 if the two numbers are equal. Expected Output: 95 0 99 Click me to see the solution
11. Write a C program that checks if two given integers are in
the range of 40 to 50 inclusive, or if they are both in the range of 50 to 60 inclusive. Expected Output: 0 0 1 1 Click me to see the solution
12. Write a C program that takes two positive integer values as
input and checks if either of them is in the range of 20 to 30 (inclusive). If at least one number falls in this range, the program returns the larger value. Otherwise, it returns 0. Expected Output: 0 30 25 28 Click me to see the solution
13. Write a C program to check if two given non-negative
integers have the same last digit. Expected Output: 0 1 1 0 Click me to see the solution
14. Write a C program to check whether the sequence of
numbers 1, 2, 3 appears in a given array of integers somewhere. Expected Output: 1 0 1 Click me to see the solution
15. Write a C program to count the number of 5's adjacent to
each other in an array of integers. Consider the situation where the second 5 is actually a 6. Expected Output: 1 2 1 Click me to see the solution
16. Write a C program to check if a triple is present in an array of
integers or not. If a value appears three times in a row in an array it is called a triple. Expected Output: 0 0 1 Click me to see the solution
17. Write a C program to compute the sum of the two given
integers. If the sum is in the range 10..20 inclusive return 30. Expected Output: 29 30 39 30 Click me to see the solution
18. Write a C program that accepts two integers and checks
whether either one of them is 5 or their sum or difference is 5. If any of these conditions are met, the program returns true. Otherwise, it returns false. Expected Output: 1 0 1 Click me to see the solution
19. Write a C program that checks if a given non-negative integer
is a multiple of 13 or one more than a multiple of 13. For example, if the given integer is 26 or 27, the program will return true, but if it is 25 or 28, the program will return false. Expected Output: 1 1 1 0 Click me to see the solution 20. Write a C program that checks if a given non-negative number is a multiple of 3 or 7, but not both. Expected Output: 1 1 0 Click me to see the solution
21. Write a C program to check whether a given number is within
2 of a multiple of 10. Expected Output: 0 0 1 1 Click me to see the solution
22. Write a C program to compute the sum of the two given
integers. Return 18 if one of the integer values given is in the range 10..20 inclusive. Expected Output: 10 18 18 241 Click me to see the solution
23. Write a C program to check whether it is possible to add two
integers to get the third integer from three given integers. Expected Output: 1 0 1 Click me to see the solution
24. Write a C program that checks if y is greater than x and z is
greater than y, given three integers x, y, and z. If both conditions are true, the program returns true. Otherwise, it returns false. Expected Output: 1 1 0 Click me to see the solution
25. Write a C program to check if two or more nonnegative
integers have the same rightmost digit. Expected Output: 1 1 0 Click me to see the solution
26. Write a C program to check three given integers and return
true if one of them is 20 or more and less than one of the others. Expected Output: 1 1 0 Click me to see the solution
27. Write a C program to find the larger of two given integers.
However if the two integers have the same remainder when divided by 5, choose the smaller integer. If the two integers are the same, return 0. Expected Output: 11 20 0 Click me to see the solution
28. Write a C program to check two given integers. Each integer
is in the range 10..99. Return true if a digit appears in both numbers, such as the 3 in 13 and 33. Expected Output: 1 0 1 Click me to see the solution
29. Write a C program to compute the sum of three given
integers. Return the third value if the two values are the same. Expected Output: 16 23 12 18 Click me to see the solution
30. Write a C program to compute the sum of the three integers.
Do not count a value that is 13 and add it to the sum. Expected Output: 16 23 10 0