Write a program calculate and print the sum of even and odd integers of the
first n natural numbers.
Answers
Answered by
2
Answer:
Program in Python Language.
maximum = int(input("Enter the Maximum Value : "))
even_sum = 0
odd_sum = 0
for number in range(1, maximum + 1):
if(number % 2 == 0):
even_sum = even_sum + number
else:
odd_sum = odd_sum + number
print("The Sum of Even Numbers from 1 to",maximum,"=",even_sum )
print("The Sum of Odd Numbers from 1 to ",maximum,"=",odd_sum)
Enter the Maximum Value : 10
The Sum of Even Numbers from 1 to 10 = 30
The Sum of Odd Numbers from 1 to 10 = 25
✨
Answered by
2
ɧɛƖƖơ ɱąɬɛ
>> ɪᴛs ᴜsɪɴɢ ᴘʏᴛʜᴏɴ ʟᴀɴɢᴜᴀɢᴇ
Answer:
ᴘʟᴇᴀsᴇ ʀᴇFᴇʀ ᴛᴏ ᴛʜᴇ ᴀᴛᴛᴀᴄʜᴍᴇɴᴛs Fᴏʀ ᴛʜᴇ ᴀɴsᴡᴇʀ...
ɴᴏᴛᴇ:
- Fɪʀsᴛ ᴀᴛᴛᴀᴄʜᴍᴇɴᴛ ᴄᴏɴᴛᴀɪɴs ᴛʜᴇ ᴘʀᴏɢʀᴀᴍ
- sᴇᴄᴏɴᴅ ᴀᴛᴛᴀᴄʜᴍᴇɴᴛ ᴄᴏɴᴛᴀɪɴs ᴏᴜᴛᴘᴜᴛ
ɧơ℘ɛ ıɬ ɧɛƖ℘ʂ ყơų ☺
Attachments:
Similar questions