click on this link......

LinkGrand.com

Saturday, 30 March 2013

Modulus operator in C

Modulus Operator
    The modulus operator in C is the % sign. It is used to find the remainder of an integer division.  This operator can be used only with integer data types.
e.g.
int a,b,c;
a=10;
b=3;
c = a%b;
Then c will contain the answer 1, i.e., the remainder of the integer division.

Write a program to
1) Ask for a two digit number and find the sum of the digits.
2) Ask for a four digit number and find the product of the digits.
3) Ask for a three digit number and find the sum of the first and third digit.
4) Ask for a four digit number and find the difference of the first and third digit and the quotient of the second and fourth digit.
5) Ask for a four digit number and find the sum of all the digits.

No comments:

Post a Comment