C Program To Count Digit k in Number n

preview_player
Показать описание

Lets write a C program to count the number of occurrences of digit k in user input positive integer number n, using iterative logic. We will be using while loop to iterate in this program.

For Example:
If user inputs n = 1550, and k = 5, then our C program should find how many times digit 5 is present in number 1550.

Note: (num % 10) fetches last digit in num. If num = 1234; (num%10) fetches the last digit from right, which is 4.

(num/10) removes the last number from right. If num = 1234; (num/10) removes last digit i.e., 4 and the result of (num/10) will be 123.

C Programming Interview / Viva Q&A List

C Programming: Beginner To Advance To Expert
Рекомендации по теме
Комментарии
Автор

Sir if we have don't have any number which has occurred then how will we display the result
Like num =102505 and k= 3 then it's obvious that no result will be coming, but how can we display the message that the number has not occurred in the above program

VarunVerma
Автор

Can u please update this problem in python

sindhumathiviji