To add odd numbers upto 15 using for loop. c language program
Attachments:
Answers
Answered by
1
Answer:
#include <stdio.h>
int main() {
int i , arr[15] ,total = 0;
for(i = 1; i < 16; i++)
{
if(i%2 == 1)
{
arr[i] = i;
total = total + arr[i];
}
}
printf("Sum of odd numbers is %d" , total);
return 0;
}
Explanation:
output is 64
Similar questions