Chapter:

C-Programs-on-integers

C Program to Calculate Sum of Odd & Even Numbers:

This is a C program to find the sum of odd and even numbers from 1 to N.

Problem Description

The program takes the number N and finds the sum of odd and even numbers from 1 to N.

Problem Solution

  • Take the number N upto which we have to find the sum as input.

  •  Using for loop take the elements one by one from 1 to N.

  • Using if,else statements separate the element as even or odd.

  • Add the even and odd numbers separately and store it in different variables.

  • Print the sum separately and exit.

Program/Source Code

#include

 

void main()

{

    int i, num, odd_sum....

Show More

All Chapters

View all Chapter and number of question available From each chapter from C-programming-