C Program to Print Sum of Odd Numbers between 1 to 100

In this program, we will display the sum of all odd numbers from 1 to 100. We have used for loop and will increment a number by 2 and make sum of it in previous result. Finally we will print sum of console.



Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
    int i, sum=0;
    clrscr();

    for(i=1; i<=100; i = i+2)
    {
        sum = sum + i;
    }
    printf("Sum of all odd numbers between 1 - 100 is: %d", sum);
    getch();
}
Output
Sum of all odd numbers between 1 - 100 is: 2500