easy
1 views
Atleast One Number 100
Check if at least one of two given integers is exactly 100 and print 'yes' or 'no' accordingly.
Understand the Problem
Problem Statement
The numbers are passed as the input to the program. If at least one of the numbers is equal to 100, the program must print yes. Else the program must print no.
Constraints
- The input consists of exactly two integers separated by a space
- Each integer can be any valid 32-bit signed integer (-2,147,483,648 to 2,147,483,647)
- The program should handle edge cases like negative numbers and zero
- Output must be exactly "yes" or "no" (lowercase, no quotes)
Examples
Example 1
Input
50 100Output
yesExplanation
Since the second number (100) equals 100, the condition is satisfied, so the output is "yes".
Example 2
Input
34 60Output
noExplanation
Neither 34 nor 60 equals 100, so the condition is false, and the output is "no".
Example 3
Input
100 100Output
yesExplanation
Both numbers equal 100, so the condition is satisfied, and the output is "yes".
Solution
#include <stdio.h>
int main() {
int X, Y;
scanf("%d %d", &X, &Y);
if (X == 100 || Y == 100) {
printf("yes");
} else {
printf("no");
}
return 0;
}Time:O(1) - Constant time complexity as it performs only two equality comparisons regardless of input values
Space:O(1) - Constant space complexity as it uses only two integer variables
Approach:
Step-by-step explanation:
- Include header: #include <stdio.h> for input/output functions
- Read input: scanf("%d %d", &X, &Y) reads two integers from standard input
- Condition check: if (X == 100 || Y == 100) evaluates if either number equals 100
- Output result: printf("yes") or printf("no") prints the appropriate response
- Return: return 0 indicates successful execution
The logical OR operator (||) ensures that if either condition is true, the entire expression evaluates to true.
Visual Explanation
Loading diagram...