We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

15,671,763 members

If you give us that information you will probably get help.

But nobody here will do your homework.

Then we can help and he will learn something.

But if he got the whole work done here he will not learn anything. See also Griff's answer.

But I can't understand your above comment when reading the one below. Above you are saying that everybody can post anything while in the below post you are telling him to use Google instead of posting here.

Its better you don't answer instead of downvoting the answer.

Thanks

if (min < max)

{

// loop here

}

Because you have initialised the sum with zero, zero will be finally printed then.

int number;

int min, max;

int sum = 0;

Console.WriteLine("Enter the minimum number");

min = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the maximum number");

max = Convert.ToInt32(Console.ReadLine());

if (max > min)

{

for (number = min; number <= max; number++)

{

if (number % 2 != 0)

sum = sum + number;

}

Console.WriteLine(sum);

}

else if (min > max)

{

sum = 0;

Console.WriteLine(sum);

}

But there is no need for the second if. Just remove that block and pull the write outside:

if (max > min)

{

for (number = min; number <= max; number++)

{

if (number % 2 != 0)

sum = sum + number;

}

}

Console.WriteLine(sum);

`max < min`

, the loop condition will be`false`

, and the loop won't execute.The only condition you're excluding is where

`max == min`

. The specification is unclear on what happens in that case, but it seems reasonable that if the single value in the range is odd, the output should be that number rather than`0`

.It seems I have read the specification the wrong way.

Thanks