Friday 27 July 2018

DATA MINING - while
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.
 
Write a program to find whether a given number is a probable topper number or not.

Input Format:
Input consists of a single integer.

Output Format:
Output consists of a single line. Refer sample output for details.

Sample Input 1:
143


Sample Output 1:
yes
 
Sample Input 2:
344

Sample Output 2:
no

Solution:
#include<stdio.h>
int main()
{
    int n,n1,sum=0,sum1=0;
    scanf("%d",&n);
    while(n>0)
    {
        n1=n%10;
        if (n1%2==0)
        {
            sum=sum+n1;
        }
        else
        {
            sum1=sum1+n1;
        }
        n=n/10;
    }
    if(sum==sum1)
    {
        printf("yes");
    }
    else
        printf("no");
        return 0;

}

5 comments:

  1. Creative Web Studio - The Cyber Defense Company bietet als zertifiziertes Unternehmen lösungsorientierte und zeitgemässe ICT-Services für KMUs an Hauptfokus: Cloud, IT-Security und Informatik.footprinting

    ReplyDelete

Random password generator in Java

       Random password generator in Java Source code: mport java.io.*; import java.util.*; public class Main { public static void main(Str...