Hi everyone, I am writing my first ever C code but it's quite different from the "easy to use" java that I knew better. I first wrote the code in java then basically converted word for word into C using some online resources and a book. (I used notepad for this). Here is my .c code and I have no idea what to do next
Code:
#include <stdio.h>
#include <math.h>
int main(void){
int digit;
int approximation;
int cont = 1;
double pi = 0.0;
int method;
while(cont == 1){
printf("Please enter the number of terms of the series: ");
scanf("%d", &approximation);
printf("Please enter the number of significant digit you wish to see: ");
scanf("%d", &digit);
printf("Which approximation would you like to use? Please enter the corresponding number (1 or 2): ");
scanf("%d", &method);
if(method == 1){
int i;
for(i = 1; i <= approximation; i++){
pi += 4*pow(-1, i+1)/(2*i-1);
}
printf("pi = %2.*f\n", digit-1, pi);
}
if(method == 2){
int i;
for(i = 1; i <= approximation; i++){
pi += pow(12, 0.5)*pow(-1, i+1)/((2*i - 1)*(pow(3, i-1)));
}
printf("pi = %2.*f\n", digit-1, pi);
}
printf("Would you like to run this program again? (1 for Yes, 0 for No)");
scanf("%d", &cont);
if(cont != 1) printf("Thank you, come again!");
}
return 0;
}
This code basically askes the user to input 3 integers and approximate pi using 2 methods (2 series). I tried to compile it with miracle C but the result was not desired. Can someone help a poor noob? Please tell me what software I need to download, and the exact steps. Thanks