Sum of first and last digit of the number in C

#include<stdio.h>
int main(){
int n;
int temp=0;
int res=0;
printf("Enter number");
scanf("%d",&n);
temp=n%10;
n=n/10;
res+=temp;
while(n>0){
if(n/10==0){
res+=n%10;
}
n=n/10;
}
printf("%d",res);
return 0;
}
view raw first_last.c hosted with ❤ by GitHub

Comments