Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
long a,b,sum,sum1;
int i;
char result[10];
scanf("%ld %ld", &a,&b);
sum=a+b;
sum1=sum;
if(sum<0) sum1=-sum;
sprintf(result, "%ld", sum1);
if(sum==0)
{
printf("%ld",sum);
return 0;
}
else{
if(sum<0) printf("-");
for(i=0;i<strlen(result);i++)
{
printf("%c",result[i]);
if((strlen(result)-1-i)%3==0&&i!=strlen(result)-1)
{
printf(",");
}
}
return 0;
}
}