in c++ wap to enter a number and print the frequency of even numbers it has using while loop programs
Answers
Answered by
1
C++
Explanation:
#include <>
main()
{
m, n, count=0;("Enter any number: ");
("%d", &m);
while(m>0)
{
n= num%10;
m=m/10;
if(n%2==0)
{
count++;
}
}
("The frequency of even digits is %d ",count);
}
Note:
- n= num%10 is used to find out the last digit of entered number m and stored it in variable n.
- m= m/10 is used to remove the last digit of entered number m and update the value of m.
Similar questions