Home » Find the Sum of Last Two Digits of an Integer Number

# Find the Sum of Last Two Digits of an Integer Number

Learn about Find the Sum of Last Two Digits of an Integer Number in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Contents

#### Find the Sum of Last Two Digits of an Integer Number

The below program takes a number as input from the user. Then finds the sum of the last two digits and displays the result.

Program:

``````#include<stdio.h>

int lastDigit(int n);
int secondLastDigit(int n);

int main()
{
int number;

printf("Enter an integer number: ");
scanf("%d",&number);

printf("Sum of last two digits is = %d",sum);

return 0;
}

{
int result = lastDigit(n) + secondLastDigit(n);
return result;
}

// function for finding last digit
int lastDigit(int n)
{
return (n%10);
}

// function for finding second last digit
int secondLastDigit(int n)
{
return ((n/10)%10);
}``````

Output:

Enter an integer number: 235
Sum of last two digits is = 8

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.