Uncompleted program 🐢 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Uncompleted program 🐢

Find the sum of the n-elements of the series 1, -0.5, 0.25, -0.125, ... I tried #include <stdio. h> int main () { int n; int sum = 0; for (i=0; i<n;i++) { sum+ = a; a = -a/2; but I couldn't complete it my mind is off and how can I write this using an array!

30th Oct 2018, 4:52 PM
mo🐼
mo🐼 - avatar
2 Answers
+ 7
you have to introduce sum and a as a float datatype and also introduce i as an int datatype. You also missed commands for reading the value of n and printing the value of sum
30th Oct 2018, 5:58 PM
Peter Stark
+ 1
oops yes about the float 😅 and yes I know about the input and output but this is a just a view of what I am trying to do... and still lost literally my mind isn't working
30th Oct 2018, 8:03 PM
mo🐼
mo🐼 - avatar