Question: Write code for main with all other additional statements to get a number from the console then using the function squaresOf to display the result
Write code for main with all other additional statements to get a number from the console then using the function squaresOf to display the result to the console. (do not worry about keeping the console open). Make sure to write the function prototype, and add all needed directives. clanguage
int squaresOf(int n)
{
int sum = 0;
for (int i = n; i >= 1; i--)
{
sum = sum + i * i;
}
return sum;
}
int main() {
int n;
printf("Enter a number");
scanf_s("%d", &n);
int sum = squaresOf(n);
printf("The sum of sqaures %d is : %d ", n, sum);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
