Input
1. The digit to be found
2. The integer to be searched
Output
The first line will contain a message prompt to input the digit to be found.
The second line will contain a message prompt to input the integer.
The last line contains the appropriate string.
Enter·the·digit·(0·-·9):·1
Enter·the·integer:·231214238
Yes
Test Case 2
Enter the digit (0 - 9): 0
Enter the integer: 123456
No
#include <stdio.h>
int main() {
int d, num;
printf("Enter the digit (0 - 9): ");
scanf("%d", &d);
printf("Enter the integer: ");
scanf("%d", &num);
if (d == 0 && num == 0) {
printf("Yes\n");
return 0;
}
while (num > 0) {
if (num%10 == d) {
printf("Yes\n");
return 0;
}
num /= 10;
}
printf("No\n");
return 0;
}
Comments
Leave a comment