#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;
}
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);
1 Like