Computer Science, asked by amalrajappunadukkunn, 1 month ago

Write a C program to find the sum of squares of odd number

Answers

Answered by HandsomeHunkk
1

Explanation:

To find sum of odd numbers we must iterate through all odd numbers between 1 to n. Run a loop from 1 to N , increment 1 in each iteration. The loop structure must look similar to for(i=1; i<=N; i++) . Inside the loop add sum to the current value of i i.e. sum = sum + i .

Answered by amikkr
0

#include<stdio.h>

void main()

{

int i, n, sum=0;

printf("enter the terminating odd number: ");

scanf("%d",&n);

for(i=1;i<=n;i=i+2){

sum = sum + (i*i);

}

printf("sum of squares of odd numbers till n is: %d",sum);

}

#SPJ3

Similar questions