Norway


#include<stdio.h>

 

float calc(float temp)

{

      float value;

      value = 1 / (1 + temp * temp);

      return (value);

}  

                      

int main()

{

      int interval, limit, count = 0;

      float upper_limit, lower_limit, interval_gap, sum = 0;

      printf(“nLower Limit:t”);

      scanf(“%f”, &lower_limit);

      printf(“nUpper Limit:t”);

      scanf(“%f”, &upper_limit);

      printf(“nTotal Intervals:t”);

      scanf(“%d”, &interval);

      interval_gap = (upper_limit lower_limit) / interval;

      printf(“nInterval Gap:t%fn”, interval_gap);

      limit = interval / 6;

      if(interval % 6 == 0)

      {

            while(count < limit)

            {

                  sum = sum + ((3 * interval_gap / ) * (calc(lower_limit) + calc(lower_limit + 2 * interval_gap) + 5 * calc(lower_limit + interval_gap) +

                        6 * calc(lower_limit + 3 * interval_gap) + calc(lower_limit + 4 * interval_gap) + 5 * calc(lower_limit + 5 * interval_gap) +

                        calc(lower_limit + 6 * interval_gap)));  

                        lower_limit = lower_limit + 6 * interval_gap;  

                  count = count + 1;

            }

            printf(“nWeddle’s is satisfied.nnEvaluated Result:t%fn”, sum);

      }

      else

      {

            printf(“nThe Weddle’s Rule is not satisfiedn”);

      }      

      return 0;  

}



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here