Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment 4 use sept 29 before 5 pm by Blackboard\" Attach a copy of your progr

ID: 670815 • Letter: A

Question

Assignment 4 use sept 29 before 5 pm by Blackboard" Attach a copy of your program and a copy of your output Sending one file with the two solutions in microsoft word format or pdf Create a C program with 3 functions that arc called from the main program: Function a) Ask for float number to be stored in the variable sidel Function b) Ask for another float number to be stored in the variable side2. Function c) Receive the variables: side 1 and side 2 and calculate a variable side3 using the formula: side3 = Function d) Print the result sidc3 as float with 2 decimals. Add two function to the problem 1: Function e) Round side3 to the next integer Function f) Round side3 to lower integer

Explanation / Answer

#include <stdio.h>
#include<math.h>

float input() {
   float temp;
   printf(" Enter side value = ");
   scanf("%f ", &temp);
   return temp;
}

float calc(float s1, float s2) {
   return sqrt((s1*s1) + (s2*s2));
}

void print(float s1, float s2, float s3) {
   printf(" The side 1 is %.2f", s1);
   printf(" The side 2 is %.2f", s2);
   printf(" The side 3 calculated is %.2f", s3);
}

int main(void) {
   // your code goes here
  
   float side1, side2,side3;
  
   side1 = input();
   side2 = input();
  
   side3 = calc(side1, side2);
   print(side1, side2, side3);
  
  
   return 0;
}

----------------------------------------------------------------------------------------------------------------

#include <stdio.h>
#include<math.h>

float input() {
   float temp;
   printf(" Enter side value = ");
   scanf("%f ", &temp);
   return temp;
}

float calc(float s1, float s2) {
   return sqrt((s1*s1) + (s2*s2));
}

void print(float s1, float s2, float s3) {
   printf(" The side 1 is %.2f", s1);
   printf(" The side 2 is %.2f", s2);
   printf(" The side 3 calculated is %.2f", s3);
}

int toCeil(float s) {
   return ceil(s);
}

int toFloor(float s) {
   return floor(s);
}

int main(void) {
   // your code goes here
  
   float side1, side2,side3;
  
   side1 = input();
   side2 = input();
  
   side3 = calc(side1, side2);
   print(side1, side2, side3);
   printf(" Round side 3 to next integer %d", toCeil(side3));
   printf(" Round side 3 to lower integer %d", toFloor(side3));
  
  
   return 0;
}