c program to find sum of N odd number

c program to find odd number

Program:-

Method 1
c program to find sum of odd number using for loop



Method 2
c program to find sum of odd number using while loop


Method 3
c program to find sum of odd number using do while loop



Output:-

Enter a number
5
sum of odd number 9

3 Comments

  1. not understandable............

    ReplyDelete
  2. Sorry to say, but the program is wrong. i is being incremented for both even and odd numbers. So actually the output should be 1+3+5+7+9 = 25. Because i increments for both even and odd numbers, you get the output as 9 (1+3+5=9)

    ReplyDelete

Add your comments here

Back to Top