/*Include necessary libraries*/ #include #include void main() { /* Define & initialize variables */ int int_one, int_two, int_three, int_four, int_five; int sum=0, diff=0; float root=0; /* Prompt for input of data */ printf("\n\nPlease enter 5 integer values, pressing enter after each number: \n"); printf("First Number: "); scanf("%d", &int_one); printf("Second Number: "); scanf("%d", &int_two); printf("Third Number: "); scanf("%d", &int_three); printf("Fourth Number: "); scanf("%d", &int_four); printf("Fifth Number: "); scanf("%d", &int_five); /* Because we are dividing by int_four + int_five, the sum !=0 */ while ((int_four + int_five)==0) { printf("\n\nThe sum of the fourth and fifth number cannot be zero.\n"); printf("Please re-enter each number as prompted below:\n"); printf("Fourth Number: "); scanf("%d", &int_four); printf("Fifth Number: "); scanf("%d", &int_five); } /* Note: each integer must be converted to float before multiplaction & division as they will be used in sqrt()*/ root = ((float)int_one * (float)int_two * (float)int_three)/(float)(int_four + (float)int_five); /* Because we are taking a square root, the product of the first three numbers divided by the sum of the fourth and fifth cannot be <0 */ while (root<0) { printf("\nPlease enter the first number with the opposite sign\n"); printf("of what was originally entered. This will allow us\n"); printf("to use the square root function.\n"); printf("Original value of first number: %d\n", int_one); printf("Enter new value: "); scanf("%d", &int_one); /* Re-calculate root with new numbers */ root = ((float)int_one * (float)int_two * (float)int_three)/((float)int_four + (float)int_five); } /* Display new values */ printf("\n\nThe values which have been stored are:\n"); printf("%d %d %d %d %d", int_one, int_two, int_three, int_four, int_five); /* Sum of all five integers */ sum = int_one + int_two + int_three + int_four + int_five; /* Difference of third and second integers */ diff = int_three - int_two; /* Square root of product of first three divided by sum of last two */ root = sqrt(root); /* Display values of sum, diff, root */ printf("\n\nThe sum of all five integers is: %d\n\n", sum); printf("The difference of the third and second integers is: %d\n\n", diff); printf("The square root of the product of the first three integers divided\n"); printf("by the sum of the last two integers is: %f\n\n\n", root); /* End of program */ }