C program to find sum of first n odd positive numbers. Take a number n as input.
* C program to print the sum of first n odd positive numbers
/* odd numbers are integers */
int count, n, sumOfOddNum=0;
/* First positive odd numbers starts from 1 and end at n. */
printf(“Enter value of n : n”);
/* Find the sum of first n odd positive numbers */
/*Positive odd numbers are 1,3,5,7….
* So increment count = 1 by 2 each time */
for(count=1; count<=n; count=count+2)
sumOfOddNum = sumOfOddNum + count;
printf(“Sum of first n odd numbers = %d”, sumOfOddNum);