//cout << "Enter a Number:";
cin >> number;
first = number % 10;
while(number != 0)
{
last = number % 10;
number = number / 10;
}
sum = first + last;
//cout << "Sum of First and Last Digit of Given Number is : " << sum;
cout << sum;
return 0;
Just because of you printed “Enter a Number:” and "Sum of First and Last Digit of Given Number is :"
You just need to print expected output nothing else
The “\n” character is missing after your cout statement. Therefore all output will be on the same line and the judge won’t accept it as correct answer.