yes. /* trapezoid.c */ #include #include float f(float); float a; float b; float x; float h; float sum; int n; int i; int main() { printf("Enter value for a: "); scanf("%f", &a); printf("Enter value for b: "); scanf("%f", &b); printf("Enter number of rectangles: "); scanf("%d", &n); h = (b - a) / n; sum = (0.5 * h) * (f(a) + f(b)); printf("%f\n", sum); for (i = 1; i < n; i++) { sum = sum + h * f(a + (i * h)); printf("%f\n", sum); } printf("The value of the integral is: %f\n", sum); } float f(float x) { float value; /* define function here */ value = x*x + 3; return value; }
// Source: Deepanshu Bhatti Solutions
#include<iostream>
#include<cmath>
using namespace std;
float f (float x)
{
return pow (x,3) + pow (x,2) - (4*x) - 5;
}
int main()
{
float a, b, d, i, n;
float I=0, J=0, A, K=0, E=0;
cout << " Given: f(x) = x^3 + 2x^2 - 4x - 5" << endl;
cout << "Enter lower limit: ";
cin >> a;
cout << "Enter upper Limit: ";
cin >> b;
cout << "Enter the number of intervals: ";
cin >> n;
d = (b - a) / n;
for (i=0; i<=n; ++i)
I = I + f (a + (i * d));
for (i=1; i<n; ++i)
J = J + f (a + (i * d));
A = (d / 2) * (I + J);
cout << "Definite integral: " << A << endl;
for (i=0; i<=n; ++i)
K = K + a + (i * d);
E = -((b - a) * d * d * ((6 * (K / n) + 4) / 12));
cout << "Total error: " << E << endl;
}
#include
#include
using namespace std;
float f (float x)
{
return pow (x,3) + pow (x,2) - (4*x) - 5;
}
int main()
{
float a, b, d, i, n;
float I=0, J=0, A, K=0, E=0;
cout << " Given: f(x) = x^3 + 2x^2 - 4x - 5" << endl;
cout << "Enter lower limit: ";
cin >> a;
cout << "Enter upper Limit: ";
cin >> b;
cout << "Enter the number of intervals: ";
cin >> n;
d = (b - a) / n;
for (i=0; i<=n; ++i)
I = I + f (a + (i * d));
for (i=1; i J = J + f (a + (i * d)); A = (d / 2) * (I + J); cout << "Definite integral: " << A << endl; for (i=0; i<=n; ++i) K = K + a + (i * d); E = -((b - a) * d * d * ((6 * (K / n) + 4) / 12)); cout << "Total error: " << E << endl; } // Source: Deepanshu Bhatti Solutions
Write and run a client and a server program in C-language using UDP
Yes.
How to write the program un Assembly language to set a password for personal computers?
first think of the logic and then write the statements
Yes, you can write a program in C language which connects to a database.
Write and run a client and a server program in C-language using UDP
write an assembly language program to find sum of N numbers
write a program to print A to Z on screen in c?
Yes.
A program that understand what a human would write and be able to transform that into instructions that a computer could understand.
How to write the program un Assembly language to set a password for personal computers?
A program that understand what a human would write and be able to transform that into instructions that a computer could understand.
AdvantageThe only advantage is that program of machine language run very fast because no translation program is required for the CPU.DisadvantagesIt is very difficult to program in machine language. The programmer has to know details of hardware to write program.The programmer has to remember a lot of codes to write a program which results in program errors.It is difficult to debug the program.
write program to concatenating two sting in 8086 assembly language
ponka
first think of the logic and then write the statements
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.