# plz tell me the coding of this question

Q:Write a C function to receive an integer of 3 digits then calculates and returns the sum of the MSD and the LSD. For example if your function received 345 it should return 8 ?

answered Nov 20, 2017 by Tomberry64
You can use the following function

unsigned int SumOfFirstAndThirdDigit(unsigned int Num)
{
if(Num > 999) Num = 999;

return ((Num / 100) + (Num % 10));
}
answered Nov 20, 2017 by (300 points)
#include <stdio.h>

int main()
{
printf("Enter a three digit number\t");
int n;
scanf("%d",&n);
if(n>=101 && n<=999)
{
printf("%d",(n/100)+(n%10));
}
else
{
printf("Enter a valid three digit number");
}

return 0;
}
commented Nov 24, 2017 by ganji kalyani
y dont u take  100 in if condition
commented Nov 24, 2017 by ganji kalyani
#include <stdio.h>
#include<math.h>
int main(int argc,char* argv[])
{
int n=atoi(argv[1]);
int s,a=0,r,p,k;
k=n;
while(n>0)
{
r=n%10;
n=n/10;
a++;
}
p=a-1;
s=(k/pow(10,p))+(k%10);
printf("%d",s);

}//this code is efficient for any number
commented Dec 5, 2017 by (230 points)
Exactly because 100 is also a three digit number
answered Nov 15, 2018 by anonymous
#include<stdio.h>

int main(){

int sum=0,a,b,n,d,raj,nick;

scanf("%d",&n);

nick=n;

while(n>0){

raj=n%10;

sum=raj+sum*10;

n=n/10;

}

a=nick%10;

b=sum%10;

d=a+b;

printf("%d",d);

return0;

}