**In this C Program we are going to calculate the sum of even and odd numbers in between 1 to N.**

- Source Code

#include <stdio.h> void main() { int i, num, oddsum = 0, evensum = 0; printf("Enter the value of num\n"); scanf("%d", &num); for (i = 1; i <= num; i++) { if (i % 2 == 0) evensum = evensum + i; else oddsum = oddsum + i; } printf("Sum of all odd numbers = %d\n", oddsum); printf("Sum of all even numbers = %d\n", evensum); }

- Runtime

Enter the value of num 100 Sum of all odd numbers = 2500 Sum of all even numbers = 2550