Question

In: Computer Science

how to implement h / k sqrt (n) in c programing

how to implement h / k sqrt (n) in c programing

Solutions

Expert Solution

Your problem statement is not very clear to me. The statement "h / k sqrt(n)" is not very clear. Could you explain the significance of h, k and n here?

For time being, I am providing the code to calculate sqrt(n) in C. Feel free to reach out in case of any queries.

CODE

#include <stdio.h>

int floorSqrt(int x)

{

  if (x == 0 || x == 1)

  return x;

  int start = 1, end = x, ans;

  while (start <= end)

  {   

    int mid = (start + end) / 2;

    if (mid*mid == x)

      return mid;

    if (mid*mid < x)

    {

      start = mid + 1;

      ans = mid;

    }

    else

      end = mid-1;    

  }

  return ans;

}

int main()

{

  int x = 11;

  printf("Square root of 11 = %d", floorSqrt(x));

  return 0;

}


Related Solutions

how to implement h / k sqrt(n) in c h being a constant k being the...
how to implement h / k sqrt(n) in c h being a constant k being the students k(k < 10^9) n is the two mid points in a ternary search in c programing
lace the points of the line either on N and K or on N and H.
10. Price elasticity of supply in the short run and long run The following graph shows the short-run supply curve for pears. Place the orange  (square symbol) on the following graph to show the most likely long-run supply curve for pears. (Note: Place the points of the line either on N and K or on N and H. )
Leave your answers as P(n, k), C(n, k) How many solutions are there to the following...
Leave your answers as P(n, k), C(n, k) How many solutions are there to the following equation, if a, b, c, d, e are all non-negative integers? a + b + c + d + e = 37 How many solutions are there to the previous equation, if a ≥ 4, and 2 ≤ d ≤ 4 ?
C++ PROGRAMING Implement a program to evaluate simple mathematical expressions. Assume that the original expression is...
C++ PROGRAMING Implement a program to evaluate simple mathematical expressions. Assume that the original expression is provided to the program as a text string. Allowed expression tokens: brackets “(” and “)”, integers like “4”, “15”, addition “+”, subtraction “-”, multiplication “*”, division “/”. Output can be float. Trim spaces from an expression. Brackets should contain at least one operation. Make sure that an expression is validated before it is calculated; reject the invalid expressions with appropriate message. The program must...
PROGRAMING in C RPSLS: The program that we must implement must allow two players to play...
PROGRAMING in C RPSLS: The program that we must implement must allow two players to play in the same console (there will be only one program) The program will initialize the information necessary to be able to store the name of two players and their respective markers throughout the game, to present a result message at the end of the game. 1. When the program is ready for the game to start, it will ask PLAYER1 enter your name. 2....
How to convolve x[n] and h[n] in code composer studio using c . Also tell the...
How to convolve x[n] and h[n] in code composer studio using c . Also tell the steps to see the graph of convolved signal in ccs without connecting any hardware DSPKit
Treatment of a polypeptide with Tris-(2-carboxyethyl)-phosphine hydrochloride (TCEP) yields two peptides: 1. I-Q-K-H-C-R-C-A-K-M-V-S 2. F-C-R-L-K-D-C-K-N-D Treatment...
Treatment of a polypeptide with Tris-(2-carboxyethyl)-phosphine hydrochloride (TCEP) yields two peptides: 1. I-Q-K-H-C-R-C-A-K-M-V-S 2. F-C-R-L-K-D-C-K-N-D Treatment of the intact polypeptide with Trypsin yields fragments with the following amino acid composition: (Ser, Met, Val) (Lys, Gln, Ile) (Phe, Ala, Cys2, Arg, Lys) (Asp, Asn) (Leu, Lys) (Lys, His, Asp, Cys2, Arg) a) The intact (untouched) polypeptide is labeled with 1-Fluoro-2,4-dinitrobenzene (FDNB) labeling, followed by acid hydrolysis. What will be observed? b) Name and briefly describe a method which may determine if...
Let G, H, K be groups. Prove that if G ≅ H and H ≅ K...
Let G, H, K be groups. Prove that if G ≅ H and H ≅ K then G ≅ K.
Show that the set of all real numbers of the form a+b sqrt(2)+c sqrt(3)+d sqrt(6),where a,b,c,d...
Show that the set of all real numbers of the form a+b sqrt(2)+c sqrt(3)+d sqrt(6),where a,b,c,d ∈Q, forms a subfield of R
Let S_k(n) = 1^k + 2^k + ··· + n^k for n, k ≥ 1. Then,...
Let S_k(n) = 1^k + 2^k + ··· + n^k for n, k ≥ 1. Then, S_4(n) is given by S_4(n)= n(n+1)(2n+1)(3n^2 +3n−1)/ 30 Prove by mathematical induction.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT