Why is my solution is wrong for practice Question FLOW006

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

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

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

1 Like