C++ Program to sum first and last digit of a number

      No Comments on C++ Program to sum first and last digit of a number
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,z;
cout<<"Enter any number:- ";
cin>>x;
y=x%10;
while(x!=0)
 {
  z=x%10;
  x=x/10;
 }
cout<<"Sum of first and last digit is:- "<<y+z;
getch();
}

OUTPUT:-

sum

Leave a Reply

Your email address will not be published. Required fields are marked *