(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to print sum of odd numbers between 1 to 10 - TecGlance

Header Ads

Program to print sum of odd numbers between 1 to 10



Algorithm:
Step 1: Start

Step 2: Assign i=1

Step 3: Assign sum=0

Step 4: Repeat steps 5,6&7 until i=10 reaches

Step 5: If i%2!=0 goto step 6

Step 6: Compute sum=sum+i

Step 7: Compute i=i+1

Step 8: Priint sum of odd numbers, sum

Step 9: Stop

Flowchart:

Program code:
i=1
sum=0
while i<=10:
    if i%2!=0:
        sum=sum+i
    i=i+1
print 'Sum of odd numbers',sum

No comments

Powered by Blogger.