So the time for challenge # 2 is over and here is the solution:
Problem Statement: A program that inputs an integer and displays the second last digit present in it.
Sample Input:
1) 341534
2) 95402367
3) 59
Sample Output:
1) 3
2) 6
3) 5
Solution:
#include <iostream>
using namespace::std;
int main(void)
{
int num;
int last_digit;
cout << "Enter an integer: ";
cin>>num;
last_digit = num/10%10;
cout << "Last digit of the entered integer is: "<<last_digit<<endl;
return 0;
}
This solution is submitted by Tom and is absolutely correct. Congrats Tom! :) I hope you are having fun with C++ and I look forward to your future participation as well.
Problem Statement: A program that inputs an integer and displays the second last digit present in it.
Sample Input:
1) 341534
2) 95402367
3) 59
Sample Output:
1) 3
2) 6
3) 5
Solution:
#include <iostream>
using namespace::std;
int main(void)
{
int num;
int last_digit;
cout << "Enter an integer: ";
cin>>num;
last_digit = num/10%10;
cout << "Last digit of the entered integer is: "<<last_digit<<endl;
return 0;
}
This solution is submitted by Tom and is absolutely correct. Congrats Tom! :) I hope you are having fun with C++ and I look forward to your future participation as well.