The program must accept two integers X and Y as the input. The program must print the integers having the sum of the tenth digit and unit digit as even from X to Y as the output.
Boundary Condition(s):
10 <= X, Y <= 10^8
Input Format:
The first line contains the value of X and Y separated by a space.
Output Format:
The first line contains the integers having the sum of the tenth digit and unit digit as even separated by space(s)
Example Input/Output 1:
Input:
10 15
Output:
11 13 15
Explanation:
The integers from 10 to 15 are 10, 11, 12, 13, 14 and 15.
The integers 11, 13 and 15 have the sum of the last two digits as even.
Hence 11 13 15 are printed.
Example Input/Output 2:
Input:
20 30
Output:
20 22 24 26 28
x, y = map(int, input().split())
for i in range(x, y+1):
if (i % 10 + (i // 10) % 10) % 2 == 0:
print(i, end=" ")
import java.util.Scanner;
public class EvenSumDigits {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int x = scanner.nextInt();
int y = scanner.nextInt();
for(int i = x; i <= y; i++) {
int unitDigit = i % 10;
int tenthDigit = (i / 10) % 10;
if((unitDigit + tenthDigit) % 2 == 0) {
System.out.print(i + " ");
}
}
}
}
#include <iostream>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
for(int i = x; i <= y; i++) {
int unitDigit = i % 10;
int tenthDigit = (i / 10) % 10;
if((unitDigit + tenthDigit) % 2 == 0) {
cout << i << " ";
}
}
return 0;
}
#include<stdio.h>
#include <stdlib.h>
int main()
{
int x,y;
scanf("%d %d",&x,&y);
for(int i=x;i<=y;i++)
{
int un=i%10;
int hn=(i/10)%10;
int sum=un+hn;
if(sum%2==0)
printf("%d ",i);
}
}
Leave a Reply