Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

ACM Q10929: You Can Say 11

DZone's Guide to

ACM Q10929: You Can Say 11

·
Free Resource
// description of your code here


// insert code here..
#include 
  
   
#include 
   
    
#define MAX 1000

int main()
{
    char num [ MAX ] ;
    char c ;
    int j = 0 ;
    int even=0 , odd=0 ;



    while( 1 ){
        while( ( num[ j ] = getchar( ) ) && num[ j ] != '\n'){


            if( j % 2 == 0){
                odd += num[ j ] - '0';
            }
            else{
                even += num[ j ] - '0';
            }
            j++;
        }
        num[ j ] = '\0';

        if(num[ 0 ] == '0' && j==1){
            return 0;
        }

        j = 0;
        if((even-odd)%11==0){
        printf("%s is a multiple of 11.\n",num);
        }
        else{
            printf("%s is not a multiple of 11.\n",num);
        }
        odd = 0 , even =0 ;
    }
}

   
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}