#include <stdio.h>
int main()
{
int N,sum=0;
printf("Enter the value of N:\n");
scanf("%d",&N);
printf("N=%d\n",N);
if(N<=0)
{
printf("N should be a positive integer.\n");
return 1;
}
for(int i=1;i<=N;i+=2)
{
sum= sum+=i;
}
printf("Sum of the odd number from 1 to %d is %d\n",N,sum);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: