(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to find the sum of first and last digit of a number. - TecGlance

Header Ads

Program to find the sum of first and last digit of a number.



Algorithm:
Step 1: Read a number, num

Step 2: Compute num1=num%10

Step 3: Assign num2=num

Step 4: Repeat step 5 while num2=>10

Step 5: Compute num2=num2/10

Step 6: print num1+num2

Step 7: Stop

Flowchart:

Program code:
num=int(input('Enter a number '))
num1=num%10;
num2=num
while num2>=10:
    num2=num2/10;
print num1+num2

No comments

Powered by Blogger.