Explain the logic
k=num%10;
sum=sum+k;
num=num/10;

Answers were Sorted based on User's Feedback



Explain the logic k=num%10; sum=sum+k; num=num/10; ..

Answer / rudrapathi

It is the logic for adding the digits of given number

for example no is 1234

output is 1+2+3+4=10

Is This Answer Correct ?    27 Yes 1 No

Explain the logic k=num%10; sum=sum+k; num=num/10; ..

Answer / bariki shanmukha[anantapuram,m

I wil take 3 variables such as,sum=0,k,num[IT REPRESENTS
GIVEN NUMBER BY THE USER].

itr1 itr2 itr3 itr4 itr5

k : - 4 3 2 1

sum: 0 4 7 9 10

num: 1234 123 12 1 0

like that exucution wil b starts which is above mentioned.

Is This Answer Correct ?    11 Yes 3 No

Explain the logic k=num%10; sum=sum+k; num=num/10; ..

Answer / cathie

reverse of a number

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More General Aptitude Interview Questions

431 x 32(probably ) is represented by 15356(probably) in some number system ki what will it represent when converted from that system to decimal.

1 Answers   eLitmus,


Which actor played the role of Mahatama Gandhi in the film 'Gandhi'? a)Paresh rawal b) ben kingsley c) abhijit

7 Answers   Sodexo,


Information about "Jeane D Arc" and picture?

0 Answers  


A person has to cover the fixed distance through his horses. There are five horses in the cart. They ran at the full potential for the 24 hours continuously at constant speed and then two of the horses ran away to some other direction. So he reached the destination 48 hours behind the schedule. If the five horses would have run 50 miles more, then the person would have been only 24 hours late. Find the distance of the destination.

4 Answers   Infosys,


A man walks from 9.15 to 5.15 from monday to friday and 9.00 to 12.00 on saturday.Each day 0.45 min lunch. How much time he walks in a week

10 Answers   CitiGroup, Ramco,






Find the next letter in the series B,F,J,P ---

0 Answers   DSQ Software,


A can have a piece of work done in 8 days, B can work three times faster than the A, C can work five times faster than A. How many days will they take to do the work together ?

0 Answers   Mu Sigma,


Number Series 10,2,8,2,6,2,?

11 Answers   TCS,


Perimeter of the back wheel = 9 feet, front wheel = 7 feet on a certain distance, the front wheel gets 10 revolutions more than the back wheel .What is the distance?

8 Answers   3i Infotech, C DAC, Canara Bank, CMC, GE, Geodesic, Infosys, TCS,


15 : 50 :: 18 : ? (A) 55 (B) 59 (C) 64 (D) 62 answer is 59 but how?

4 Answers   FCI,


(165)2 - (164)2 =

6 Answers  


A student is ranked 13th from right and 8th from left. How many students are there in totality ?

0 Answers   Canara Bank, EDS,


Categories