Thursday, April 4, 2013

C++ code to get sum of all odd numbers in given range


Sum of ODD Numbers in the Given Range




#include<stdio.h>
#include <iostream>
using namespace std;

int main(){

    int number;
    int min,max;
    long sum =0;
 
    cout << "Enter the minimum range: ";
    cin >> min;

    cout << "Enter the maximum range: ";
    cin >> max;

    for(number = min;number <= max; number++)
         if(number % 2 !=0)
             sum = sum + number;

    cout << "Sum of odd numbers in given range is: " << sum;
 
    return 0;

}
OUTPUT:
Enter the minimum range: 25
Enter the maximum range: 30
Sum of odd numbers in given range is: 81



---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
------------------------------------------------
Sum of ODD Numbers in the Given Range
write a program to calculate sum of all odd numbers
Program that prints odd numbers, even numbers and the numbers
Program to find out the sum of odd and even numbers between
IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ