Finding Odd Numbers

I am trying to write a short and concise C++ program to find the following:
6 non repeating odd numbers who's sum equals 60.
The smallest odd number equals to 1.
The largest odd number equals to 17.
Please Help. I writing too many lines of code and I am told it can be done in simpler ways.
Thank You.
Maybe something like:

1
2
3
4
5
6
7
8
int num = 60;
int odd = 17;

for(int i = 17; i>0;i--){
     if(i%2 != 0 && num>=odd){
           num-=odd;
      }
}

@naratu9333 we can eleminate one of the if checks
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>


int main()
{
  int i,sum=60;
  for(i=17;i>0;i-=2)
    if((sum-i)>=0)
       {sum-=i;
        cout<<i<<endl;
       }
return 0;
}
Topic archived. No new replies allowed.