You are not logged in. Please login at to post your questions!


Problem1 in Peer section

Sorry to bother you again but can plz help me understand ehy im getting WA for Problem 1(Problem code: CMB01) of peer section. Link to my submission: Thank you in advance again.

asked 02 Nov '14, 20:30

tataisap's gravatar image

accept rate: 0%

Well,you are getting WA because your code for reversing the number is not actually reversing the number.after the execution of for loop the right most digit of the number is used in addition.i.e if the number is 12345,then in each iteration you are updating a1 as mod of number/10,i.e
iteration no.1 : a1=12345%10=5
iteration no.2 :a1=1234%10=4
iteration no.3 : a1=123%10=3
iteration no.4 : a1=12%10=2
iteration no.5 : a1=1%10=1
thus your reversing code is outputting the right most digit of number.Rather than writing
for(int i=0;a>0;i++)
{ a1=a%10;
Try this
for(int i=0;a>0;i++)
{ a1=a1*10;
This will give you the reversed number.Do check it out.Do the same editing for other 'for' loops too.


answered 02 Nov '14, 22:49

ansh1star033's gravatar image

accept rate: 9%

its still not working!! :( Link:

(03 Nov '14, 00:55) tataisap2★

Hey,why are you printing the reversed nos. i.e a and b,that is not asked.You have to give the output as asked in the question,just remove those printf's for integers separately,n only print the final sum.This should get you AC.Try it.

(03 Nov '14, 01:50) ansh1star0333★
(03 Nov '14, 13:30) tataisap2★

O sorry i had mistakenly deletedthe \n so it wasnt working now ive got it thank you very much:)

(03 Nov '14, 13:49) tataisap2★

Cheers! :-)

(03 Nov '14, 15:24) ansh1star0333★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Nov '14, 20:30

question was seen: 544 times

last updated: 03 Nov '14, 15:24