Q.1 Write a program to compulsory Marks : 10 calculate and print the sum of odd numbers and sum of even numbers for the first n natural numbers. The integer n is to be entered by the user
Answers
Answered by
0
Answer:
1Take the number N upto which we have to find the sum as input.
2. Using for loop take the elements one by one from 1 to N.
3. Using if,else statements separate the element as even or odd.
4. Add the even and odd numbers separately and store it in different variables.
5. Print the sum separately and exit
Similar questions