|
|
back to boardwhy does this not work?all inputs give correct output Posted by Niloy 30 Jun 2013 02:57 #include <stdio.h> #include<stdlib.h>
int main() { int arr[5],arr1[5],arr2[5],i,a=0,b=0,n,x=0,y=0; printf("Enter number"); scanf("%d",&n); x=n+1; y=n-1; while(n>0) { for(i=5;i>=0;i--) { arr[i]=n%10; n=n/10; } } a=( arr[0]+arr[1]+arr[2]); b=(arr[3]+arr[4]+arr[5]); // printf("%d%d",a,b); if((a-b==1)||(a-b==-1)) { while(x>0) { for(i=5;i>=0;i--) { arr1[i]=x%10; x=x/10; } } while(y>0) { for(i=5;i>=0;i--) { arr2[i]=y%10; y=y/10; } } if ((arr1[0]+arr1[1]+arr1[2]==arr1[3]+arr1[4]+arr1[5])||(arr2[0]+arr2[1]+arr2[2]==arr2[3]+arr2[4]+arr2[5])) { printf("\nYes");} else { printf("\nNo");} } else { printf("No"); } return 0; } |
|
|