The sum of all odd numbers between a and b inclusive where


Question: The sum of all odd numbers between a and b (inclusive). Where a and b are read in by the user.

Can you find the error in this code and if need to change it then please change and provide the desired code. Thanks!

int main()

{

int a, b , sum;

cout << "Enter the first integer: ";

cin >> a;

cout << "Enter the second integer: ";

cin >> b;

  for (a, b; ; a++,b++)

   if (a % 2 == 1 && b % 2 == 1 )

sum = a + b;

cout << sum << endl;

getch ();

}

Add comments in code section. Code this program in C++ programming.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: The sum of all odd numbers between a and b inclusive where
Reference No:- TGS0949867

Expected delivery within 24 Hours