C Program to check whether the given digit is occurred in a Number

Description

Sample Input:
6372 3
Sample Output:
3 is occurred in 6372

Solution

#include<stdio.h>
int main()
{
	int n,num,digit,rem;
	scanf("%d %d",&num,&digit);
	n=num;
	while(num!=0)
	{
		rem=num%10;
		if(rem==digit)
		{
			printf("%d is occured in %d",digit,n);
			return 0;
		}
		num/=10;
	}
	printf("%d is not occured in %d",digit,n);
	return 0;
}
		

Explanation

refer video tutorial



Interesting Pattern Programs: for more Patterns

Input:
5
Output:
*
**
***
****
*****
****
***
**
*Solution
Input:
5
Output:
    *
   ***
  *****
 *******
*********
 *******
  *****
   ***
    *Solution
Input:
5
Output:
*        *
**      **
***    ***
****  ****
**********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********Solution
Input:
5
Output:
*       *
**     **
***   ***
**** ****
*********
**** ****
***   ***
**     **
*       *Solution
Input:
5
Output:
*********
 *******
  *****
   ***
    *
   ***
  *****
 *******
*********Solution