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

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...
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.
Kernal Modul Programing Quenstion : Implement the following 4 conditions in kernel module programming. 1. Implement...
Kernal Modul Programing Quenstion : Implement the following 4 conditions in kernel module programming. 1. Implement a timer module using the timer function provided by the file LINUX/timer.h 2. In module_init, the timer is initialized using setup_timer and called mod_timer to start the timer. 3. Call back function my_timer_callback when timer expires. 4. When you remove a module, delete the timer.
Which of the following bonds are polar: C-Se, C-O, Cl-Cl, O=O, N-H, C-H? In the bond...
Which of the following bonds are polar: C-Se, C-O, Cl-Cl, O=O, N-H, C-H? In the bond or bonds that you selected, which atom has the greater electronegativity?
What is ΔG° at 298 K for the following reaction? HCN( g )+N H 3 (...
What is ΔG° at 298 K for the following reaction? HCN( g )+N H 3 ( g )→C H 4 ( g )+ N 2 ( g ) ;   ΔH°=−164.1kJ;    ΔS°=−17J/K   at   298 K?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT