how to write a programm in which we enter positive integer and it will give us the sum of all odd integers upto the entered positive integer..e.g if we enter 12 it will give us the sum of 1+3+5+7+11
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
//declare and initalize input
int input = 0;
//declare and initialize total
int total = 0;
//promt user to enter a whole number
cout << "Enter a whole number: ";
//get and store the user entered number in input
cin >> input;
//loop i starting at one
//while i is less than or equal to input
//each loop increment i by 2
for(int i = 1; i <= input; i += 2)
{
//output each i
cout << i << endl;
//add each i to total
total += i;
}
//output the total
cout << total << " = Total" << endl;
return 0;
}