Writing a UNIX shell script to call a C function and redirecting data to a .txt file

Hi, I am complete new to C programming and shell scripting. I just wrote a simple C code to calculate integral using trapezoid rule. I am prompting user to pass me No. of equally spaced points , N , upper and lower limit. My code looks as follows so far:

#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#define PI 3.14159265358979323846

float fn(float x)
{ 
  float integrand;
  integrand = (1.0/(1.0+x*x));
  return integrand;
}
int main()
{
  char str[100000];
  int i,N;
  float a,b,sum=0,result=0,h;
  float error;
 
  
  printf("Enter the no of equally spaced points as a string =");
  scanf("%s", str);
  N=atoi(str);
  printf("Enter the lower limit=");
  scanf("%f",&a);
  printf("Enter the upper limit=");
  scanf("%f",&b);
  h=(b-a)/(N-1);
  for(i=1;i<=N;i++)
  {
    sum=sum+fn(a+i*h);
    result=(fn(a)+fn(b)+2*sum)*h/2;
    error = fabs((atan(b)-atan(a))-result);
    //error = PI/2.0 - result;
    
    printf("N=%d result=%f error=%f\n", i, result, error);
  }
  printf("final result =%f\n", result);
  printf("cumulative error =%f\n", error);
  
}

Now, I want to write a unix script which calls the program for N = 2^{i} for integers i from 1, 2, 3, ..., 20 and use the Unix redirect operator > to record this data in a file.

I am searching over internet how to pass argument through shell and even how to modify my code so that it reads that passed parameter, still no good answer. Your suggestions are highly appreciated. It will help me learn the unix shell scripting as well.

Please use code tags when posting code, logs etc.

You can echo values using the shell's pipe | to hand over the arguments.
You might also have a look into argc and argv in your C code to handle passed arguments.

Check this:
The GNU C Programming Tutorial

Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If you did post homework in the main forums, please review the guidelines for posting homework and repost. If this is not a homework assignment, please explain how you will use this code in a real world situation.