So the question is: Write a program in C such that it contains a function which calculates the third power of a given integer. It should calculate the third power of numbers between 1 and 10 using your function and the results should be saved in an array.
This is what I have (below). I keep getting an error from CCS on the line output=powerOfThree(int i+1);. The error says 'expected an expression'. I'm not sure what I'm doing wrong.
#include<msp430.h>
long int powerOfThree(int a);
long int arrayOfTen[10];
int powers = 3;
int output;
int i;
int temp;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
for (i = 0; i <= 10; i++)
{
output = powerOfThree(int i+1);
arrayOfTen[i] = output;
return output;
}
}
long int powerOfThree(int a)
{
int result = a*a*a;
return result;
}