Write a program that receives an integer (n) and then calculate the sum of integers 1 to n (exp. 1 + 2 + 3 + ….. + n) using for loop
so confused :(
No products are associated with this question.
Use inputdlg() to get n - look in the help for examples. Then use a for loop. Here's a hint to get you started.
theSum = 0; for k = 1 : n % your code goes here. theSum = theSum + ........ end
I don't know what you mean by exp. Do you want e to the power? Like exp(1) + exp(2) + exp(3) + .... OR do you want exp(1+2+3+.....????