When you add num%10 to sum you need to test if its a even number.A number is even if the number % 2 == 0 meaning that the remainder of the number divided by 2 is 0 since all even number are divisible by 2.

#include <iostream>
using namespace std;
int main()
{
int sum = 0 , num=10,cnt=0;
//cin>>num;
cout<<"Sum all even digits of a given number \n\n\n";
cout<<"Number = "<<num<<"\n\n\n";
while(cnt < num)
{
cnt++;
if (cnt % 2 ==0)
{
sum+=cnt;
cout<<cnt<<" + ";
}
}
cout<<" = "<<sum<<" \n\n\n";
return 0;
}

Hi everyone!, I had this confusion about the the Bucket Sort Algorithm.
I just wanna know why mostly bucket sort use the range of element in between 0 and 1 ...

Good day community,
I have completed vb.net program (a school timetabling program) and I am in the process to create a website. At the moment word -press on wamp server ...