Hey everyone ... I am looking for help before my first exam in my C class tomorrow. I have a minimal understanding of C and I was hoping someone could help me with this problem because I am stumped atm.
QUESTION: Write a comple C program that uses a FOR-loop to read in 41 integers. For each of the 41 integers, first multiply the integer by itself; if the result obtained (i.e., the squared value) is greater than 500, the original integer (before it was squared) should be added into a sum that was initialized to zero. After the loop, multiply the sum by itself and then print out the answer as an integer. Assume correct imput.
What I have so far ...
Code:
#include <stdio.h>
int main (void) {
int sum=0;
int index;
int imput;
printf("What number would you like to imput?\n");
for (index=0;index<41;index++);
{
scanf("%d", &imput);
imput=imput*imput;
if(imput>500) {
sum+=imput;
}
else(imput<=500); {
imput=sum;
}
}
sum=sum*sum;
printf("Your total is now %d.\n", sum);
return 0;
system("pause");
}
I am specifically not understanding what to do about the math and how i should use the if statement
I realize I am screwing up hard ...but I am lost as to where to go from here :C