source file  name: SumDig1_4.C

 #include<stdio.h>

int main()

{

int n,d1,d2,d3,d4,d5;

int sum=0;

//clrscr();

printf("\n enter any only 4 digit number: ");

scanf("%d",&n);

d1=n%10;

n=n/10;

d2=n%10;

n=n/10;

d3=n%10;

n=n/10;

d4=n%10;

sum=d1+d4;

printf("\n sum of first and fourth digit=%d  ",sum);

//getch();

return 0;

}

output:

enter any only 4 digit number:  1234

sum of first and fourth digit=5

enter any only 4 digit number:  2222

sum of first and fourth digit=4

enter any only 4 digit number:  6239

sum of first and fourth digit=15