Check Same Digit
The program must accept two integers N1 and N2 as the input. The program must print Valid if the tenth digit or the unit digit of N2 is present in N1. Else the program must print Invalid as the output.
Boundary Condition(s):
10 <= N1, N2 <= 99
10 <= N1, N2 <= 99
Input Format:
The first line contains the two integer values N1 and N2 separated by a space.
The first line contains the two integer values N1 and N2 separated by a space.
Output Format:
The first line contains either Valid or Invalid.
The first line contains either Valid or Invalid.
Example Input/Output 1:
Input:
12 23
Input:
12 23
Output:
Valid
Example Input/Output 2:
Input:
90 13
Valid
Example Input/Output 2:
Input:
90 13
Output:
Invalid
Invalid
Solution:-
#include<stdio.h>
#include <stdlib.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(b%10==a%10||b%10==(a/10)%10||(b/10)%10==a%10||(b/10)%10==(a/10)%10)
{
printf("Valid");
}
else
printf("Invalid");
}
Comments
Post a Comment