C Programming Tutorial

 
 
 
 

Image

#include <stdio.h>
#include <conio.h>
void main(){
     long range1,range2,totodd=0,toteven=0;
     clrscr();

     printf(\"*****SUM OF EVEN-ODD BETWEEN RANGE*****\\n\\n\");
     up:
     printf(\"Enter Lower Range : \");
     scanf(\"%ld\",&range1);
     printf(\"Enter Greater Range : \");
     scanf(\"%ld\",&range2);

     if(range1 >= range2){
      printf(\"\\nImproper Input\\n\");
      goto up;
     }

     while(range1 < range2){
        if(range1 % 2 == 0)
           toteven = toteven + range1;
    else
        totodd = totodd + range1;
        range1++;
     }

     printf(\"\\n\\nSum of Even Range is %ld\",toteven);
     printf(\"\\nSum of Odd Range is %ld\",totodd);


getch();
}

 
 
Didn't find what you were looking for? Find more on Program to find out the sum of odd and even numbers between given range