Back To C Loops Index
//program to find sum of even and odd numbers from 1 to 10 using for statement #include
#include
void main() { int i; int sumeven=0; int sumodd=0; clrscr(); for(i=1;i<=10;i++) { if(i%2==0) { sumeven=sumeven+i; } else { sumodd=sumodd+i; } } printf("\nsum of even numbers from 1 to 10 is %d",sumeven); printf("\nsum of odd numbers from 1 to 10 is %d",sumodd); getch(); }