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

×

Why is my solution is wrong for practice Question FLOW006

include<stdio.h>

main() { int t,i,n,sum=0; scanf("\n%d",&t); for(i=0;i<t;i++) { scanf("%d",&n); sum=0; while(n!=0) { sum=sum+n%10; n=n/10; } printf("\n%d",sum); } return 0; }

asked 12 Aug '18, 18:20

jaydeb_19's gravatar image

0★jaydeb_19
11
accept rate: 0%


You are not taking inputs and printing outputs in the defined format as is highlighted in the problem description.

Change scanf("\n%d",&t) to scanf("%d",&t) and printf("\n%d",sum); to printf("%d\n",sum);

link

answered 12 Aug '18, 20:16

utkalsinha's gravatar image

6★utkalsinha
851118
accept rate: 13%

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×2,379
×1,478
×948
×554

question asked: 12 Aug '18, 18:20

question was seen: 97 times

last updated: 12 Aug '18, 20:16