Answer to Question #282853 in C for Pravin Kumar

Question #282853

Write a c program to calculate sum of square root from 1 to n number.

1
Expert's answer
2021-12-27T15:51:21-0500
/**
 * Write a c program to calculate sum of square root from 1 to n number.
 **/
#include <stdio.h>
#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  float sum = 0.f;
  for (int i = 1; i <= n; i++) {
    sum += sqrtf((float)i);
  }
  printf("%0.4f", sum);
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS