FirstSumLast

    0

    0

    Mahendra Kumar

    beginnersumofdigitslogic

    If Give an integer N . Write a program to obtain the sum of the first and last digits of this number.

    #include <iostream>
    using namespace std;
    typedef long long ll;
    int main() {
    		ll n,last,first;
    		cin>>n;
    		last=n%10;
    		while(n>=10)
    		{
    			n=n/10;
    		}
    		first=n;
    		cout<<last+first<<"\n";
    	return 0;
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.