# Thread: variable declarations and arithmetic expressions

1. ## variable declarations and arithmetic expressions

ask the user for 4 integer values

5. The quotient (real, with decimals) of the square root of the
sum of the squares
divided by the sum of all the numbers.

the program runs all other operations expect #5.

How can i fix it?

Code:
```#include <stdio.h>
#include <math.h>

int main()
{

int num[4];

printf("Enter 4 numbers seperated by a space in between each:\n");
scanf("%d %d %d %d",&num[0],&num[1],&num[2],&num[3]);

printf("The sum of the 4 numbers is : %d\n", num[0]+num[1]+num[2]+num[3]);
printf("The sum of the first two numbers minus the sum of the last two is : %d\n", (num[0]+num[1])-(num[2]+num[3]));
printf("The sum of the squares of the four numbers is : %d\n", (num[0]*num[0]+num[1]*num[1]+ num[2]*num[2]+num[3]*num[3]));
printf("The quotient of the square root of the sum of the squares divided by the sum of all the numbers is : %f\n", sqrt(num[0]*num[0]+num[1]*num[1]+ num[2]*num[2]+num[3]*num[3])/(num[0]+num[1]+num[2]+num[3]);

return (0);
}```

2. What did you see?
What did you expect?

You can't just dump code and say "it doesn't work", without you saying what you expect from it (at the very least).

3. i found the problem. The program is working now.

4. THE CORRECT PROGRAM

Code:
```#include <stdio.h>
#include <math.h>

int main(void)

{

int num[4];

printf("Enter 4 numbers seperated by a space in between each:\n");

scanf("%d %d %d %d",&num[0],&num[1],&num[2],&num[3]);

printf("The sum of the 4 numbers is : %d\n", num[0]+num[1]+num[2]+num[3]);

printf("The sum of the first two numbers minus the sum of the last two is : %d\n", (num[0]+num[1])-(num[2]+num[3]));

printf("The sum of the squares of the four numbers is : %d\n", (num[0]*num[0]+num[1]*num[1]+ num[2]*num[2]+num[3]*num[3]));

printf("The quotient of the square root of the sum of the squares divided by the sum of all the numbers is : %f\n",
sqrt(num[0]*num[0]+num[1]*num[1]+ num[2]*num[2]+num[3]*num[3])/(num[0]+num[1]+num[2]+num[3]));

return (0);
}```