program
#include <stdio.h>
#include <conio.h>
void main()
{
int a, sum = 0;
printf("enter a value of a: ");
scanf("%d", &a);
for (int i = 0; i <= a; i++)
{
if (i % 2 != 0)
{
sum = sum + i;
printf("%d ", sum);
}
}
printf("\n%d is the sum", sum);
getch();
}
Enter a value of a: 7
1 4 9 16
16 is the sum
Follow our page for regular updates.
0 Comments