Can ne1 explain how these programs can be written?
1) If a five digit number is input through the keyboard, write a program to calculate the sum of its digits.
(Hint : Use the modulus operator '%'
The division operator / , returns the quotient on dividing one number by another, whereas the modulus operator % gives the remainder on dividing one number by another.
a = 12 % 3 would store 0 in a.
a = 13 % 5 would store 3 in a.
2) If a five digit no. is input through the keyboard, write a program to reverse the number.
3) If a four digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number.
And yes, one more question....
If suppose i have to find the aggregate of marks of 5 subjects entered by a user.... and i use an array for storing the marks... eg. marks[ 4 ]
this means that the marks of the 5 subjects are stored in order in the array... How do i find the aggregate now? How to add the individual array elements?
I know there is another method for doin this.. but i am interested using arrays.
Help will be appreciated...