Header Ads Widget

program to sum first and last digit of a four digit number.

#include<stdio.h>
#include<conio.h>
void main()
{
      int n,r,sum;
    printf("enter the four digit number");
    scanf("%d",&n);
   r=n%10;
   sum=sum+r;
   n=n/1000;
   r=n%10;
   sum=sum+r;
   printf("sum of first and last digit is %d ",sum);
  getch();
}


Post a Comment

1 Comments