c program to compute AREA under integral
Answer / Pradeep Kumar Verma
Here's a simple C program that computes the area under an integral using the trapezoidal rule. This program approximates the area under the curve y = f(x) between x1 and x2 by dividing the interval into n equal parts, computing the trapezoids, and summing their areas.nn```cn#include <stdio.h>n#include <math.h>nndouble f(double x); // function to be integratednint main() {n double a = 0, b = 1, n = 100, h = (b - a) / n;n double sum = 0;n int i;nn for (i = 0; i < n; i++) {n double x = a + i * h;n double y = f(x);n if (i == 0 || i == n) y *= 0.5;n sum += y;n }n printf("The approximate area under the curve is: %.16f", sum * h);n return 0;n}nn// Define the function to be integratedndouble f(double x) {n // Replace this function with your desired function.n return pow(x, 2);n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x);
What does char * * argv mean in c?
Can a pointer be volatile in c?
Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.
Explain what is the difference between null and nul?
Explain how do you print only part of a string?
Write a program to add the following ¼+2/4+3/4+5/3+6/3+... (Like up to any 12 no.s)
how c source file in converted to exe file
please help me.. how to write a code of this output?? "Enter range number:"10 1 is an odd number 2 is an even numbers 3 in an odd numbers 4 " to 10" "printing all odd numbers:" 1,3,5,7,9 "printing all even numbers:" 2,4,6,8,10 "sum of all odd numbers:25 "sum of all even numbers:30 using a C Programming ARRAY pleas pleas help.. its my project ..please :(
#include<stdio.h> int f(int,int); int main() { printf("%d",f(20,1)); return 0; } int f(int n,int k) { if(n==0) return 0; else if(n%2)return f(n/2,2*k)+k; else return f(n/2,2*k)-k; } how this program is working and generating output as 9....?
Write a C program to convert an integer into a binary string?
What is the use of bit field?