Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * test.c
- *
- * Created on: Feb 28, 2020
- * Author: cdamian
- *
- *
- *
- * calculul lui PI
- * 4x(1/1 - 1/3 + 1/5 - 1/7 ...)
- */
- #include<stdio.h>
- int main(){
- int i, n;
- int semn = +1;
- float pi = 0;
- printf("dati n: ");
- scanf("%d", &n);
- for(i = 1; i <=n ; i = i + 2){
- pi = pi + semn / (float) i;
- semn = semn * (-1);
- }
- pi *= 4;
- printf("pi = %f", pi);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement