Computer Science, asked by daud2281, 11 months ago

In the University examinations conducted during the past 5 years, the toppers registration numbers were 7126, 82417914, 7687 and 6657. Your father is an expert in data mining and he could easily infer a pattern in the toppers registration numbers. In all the registration numbers listed here, the sum of the odd digits is equal to the sum of the even digits in the number. He termed the numbers that satisfy this property as Probable Topper Numbers. Now, write a program to find whether a given number is a probable topper number or not.

Answers

Answered by chaudharibhagyashri2
8

Answer:

#include<iostream>

using namespace std;

int main()

{

   int n,n1,sum=0,sum1=0;

   cin>>n;

   while(n>0)

   {

       n1=n%10;

       if (n1%2==0)

       {

           sum=sum+n1;

       }

       else

       {

           sum1=sum1+n1;

       }

       n=n/10;

   }

   if(sum==sum1)

   {

      cout<<"Yes";

   }

   else

      cout<<"No";

       return 0;

}

Explanation:

Answered by MSFLAB3
2

Answer:

#include<iostream>

using namespace std;

int main()

{

 int n,fd,sd,td,se=0,so=0;

 cin>>n;

 fd=n%10;

 sd=(n%100)/10;

 td=(n%1000)/100;

 if(fd%2==0)

   se+=fd;

 else

   so+=fd;

 if(sd%2==0)

   se+=sd;

 else

   so+=sd;

 if(td%2==0)

   se+=td;

 else

   so+=td;

 if(se==so)

   cout<<"Yes";

 else

   cout<<"No";

}

Similar questions