# Finding remainder on dividing numbers

Here is a nifty way to find remainder on diving numbers:

Remainder on dividing by 3

To find the remainder of a number divided by 3, add the digits of the number and divide it by 3. So if the digits added together equal 8 then the number has a remainder of 2 since 8 divided by 3 has a remainder of 2.

For example, find the remainder on dividing 1,342,568 by 3.
The digit sum of 1342568 is 1+3+4+2+5+6+8 = 29.
Again, the digit sum of 29 = 2+9 = 11 = 2
So, the remainder will be 2.

Another example: Take 34,259,677,858.
The digit sum of the number is 3+4+2+5+9+6+7+7+8+5+8 = 64.
Now, the digit sum of 64 is 6+4 = 10 = 1.
So, the remainder is 1.

Similarly, the digit sum of 54,670,329,845 is 53 i.e. (5+3=) 8.
When we divide 8 by 3, we get remainder 2.
So the answer will be 2.

Remainder on dividing by 4

To find the remainder of a number divided by 4, take the remainder of the last 2 digits.  So if the last 2-digits are 13 then the number has a remainder of 1 since 13 divided by 4 has a remainder of 1.

Remainder on dividing by 5

To find the remainder of a number divided by 5, simply use the last digit.  If it is greater than 5, subtract 5 for the remainder.

Remainder on dividing by 7

Split the digits of the number in group of 3 starting from unit’s place. Add the alternate group and then find their difference. Divide the difference by 7 and get the remainder.
Consider the number 34568276.

Make triplets as written below starting from unit’s place
34.........568..........276
Now alternate sum = 34+276=310 and 568 and difference of these sums =568-310=258. Divide it by 7 we get remainder as 6.
Another example, consider the number 4523895099854
Triplets pairs are 4…523…895…099…854
Alternate sums are 4+895+854=1753 and 523+099=622
Difference =1131
Revise the same tripling process 1…131
So difference = 131-1=130

Divide it by 7 we get remainder as 4.

Remainder on dividing by 8

To find the remainder of a number divided by 8, take the remainder of the last 3-digits.  So if the last 3-digits are 013 then the number has a remainder of 5 since 13 divided by 8 has a remainder of 5.

Remainder on dividing by 9

To find the remainder of a number divided by 9, add the digits and then divide it by 9. So if the digits added together equal 13 then the number has a remainder of 4 since 13 divided by 9 has a remainder of 4.

Remainder on dividing by 10

To find the remainder of a number divided by 10 simply use the last digit.

Remainder on dividing by 11

The difference of the sums of the alternate digits is the remainder after dividing by 11 if it is positive.  If the number is negative add 11 to it to get the remainder.

Take the number 34568276 for example.

Sum of alternate digits are 3+5+8+8=24 and 4+6+2+6=18

And difference of these sums =24-18=6.
So, the remainder is 6.

Remainder on dividing by 13

Split the digits of the number in group of 3 starting from unit’s place. Add the alternate group and then find their difference. Divide the difference by 13 and get the remainder.
Consider the number 34568276.
Split the number as 34.........568..........276

Now alternate sum = 34+276=310 and 568
and difference of these sums =568-310=258

Divide it by 13 we get remainder as 11

Another example, consider the number 4523895099854
Triplets pairs are 4…523…895…099…854
Alternate sums are 4+895+854=1753 and 523+099=622
Difference =1131
Revise the same tripling process 1…131
So difference = 131-1=130

Divide it by 13 we get remainder as 0

Remainder on dividing by 27 and 37

Consider the number 34568276; we have to calculate the reminder on dividing the number by 27 and 37.

Make triplets as written below starting from unit’s place
34.........568..........276
Now sum of all triplets = 34+568+276 = 878

Dividing it by 27 we get reminder as 14
Dividing it by 37 we get reminder as 27

Another example for the clarification of the rule; take the number 2387850765.
Triplets are 2…387…850…765
sum of the triplets = 2+387+850+765=2004.
On revising the steps we get 2…004
Sum =6

Dividing it by 27 we get remainder as 6.
Dividing it by 37 we get remainder as 6.

### C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
aaaa nnnn
Explanation

### Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
1. Booking
2. Availability checking
3. Cancellation
4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

My Solution :