program to find sum of first and last digit of a number


LIST OF PROGRAMS



#include<stdio.h>
#include<conio.h>

void main()
{
long int n,sum=0,last;
 clrscr();

printf("Enter a number ");
scanf("%ld",&n);

if(n<=9&&n>=0)
printf("sum = %ld",n);

else if(n<0)
printf("WRONG INPUT");

else
{
last=n%10; /*for finding last digit of the number */
while(n>9)
{
n=n/10;
}

sum=n+last;
printf("SUM =%ld",sum);
getch();

}
}

LIST OF PROGRAMS

Comments