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>
#include<math.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
is this C language code
ReplyDelete#include
ReplyDeleteint main()
{
int n,last,first,sum;
sum=0;
scanf("%d",&n);
last=n%10;
while(n>=10)
{
n=n/10;
}
// n=fist;
sum=n+last;
printf("%d the sum of the first and last digits\n",sum);
return 0;
}