Untitled
Anonymous
plain_text
04/21/2024 4:37 PM
300 B
20
Indexable
#include<stdio.h>
int main(){
int i,n,sum=0;
printf("Enter the nth term\n");
scanf("%d",&n);
for(i=1;i<=n;i+=2){
sum+=i;
}
if(n % 2 == 1){
sum += n*n;
}
printf("%d",sum);
return 0;
}
Editor is loading...
Leave a Comment