Expand|Select|Wrap|Line Numbers
- int main ()
- {
- string s;
- char c;
- int sum=0,n=0,a[6]={0},num=0;
- cout<<"Enter a 6 digit integer \n";
- int i=0, fact=100000;
- while(i<6)
- {cin>>n;
- a[i]=n;
- num+=a[i]*fact;
- fact/=10;
- i++;
- if(i>5) break;
- }
- cout<<"The integer entered is: "<<num;
- if(num%3==0)cout<<" and is divisible by 3 (= "<<num/3<<" )";
- else cout<<" and is not divisible by 3";
- for(int i;i<6;i++)
- sum+=a[i];
- cout<<"\nSum of numerals is: "<<sum;
- if(sum%3==0)cout<<" and is divisible by 3\n";
- else cout<<" and is not divisible by 3\n";
- cout<<"\n";
- system("pause");
- return 0;
- }