Problem Description
If Give an integer N . Write a program to obtain the sum of the first and last digit of this numberCODING ARENA
#include <stdio.h>
int main()
{
int a,b,c,i,e;
scanf("%d",&a);
for(i=0;i<a;i++)
{
scanf("%d",&b);
c=b%10;
while(b>=10)
{
b=b/10;
}
e=c+b;
printf("%d\n",e);
}
return 0;
}
Test Case 1
Input (stdin)2 1234 124894
Expected Output5 5
Test Case 2
Input (stdin)1 23233
Expected Output5
No comments:
Post a Comment