Write a menu driven to the following to find the sum of the series s=1+3+5+...n
Attachments:
Answers
Answered by
1
Explanation:
#include
void main()
{
int i,n,sum=1;
printf("Enter any number n:");
scanf("%d",&n);
printf("\n1 ");
for(i=3;i<=n;i++){
printf("+ %d ",i);
sum=sum+i;
i++;
}
printf("\nSum is: %d", sum);
}
Similar questions