there are different ways of writing dis program... 1+x+(x*x)+(x*x*x*)+....has a formula for its sum... the sum for a geometric series with a as initial value and x as common ratio is (a*(pow(r,n)-1))/(r-1).... where a=1;r=x.. accept the values of x and n through keyboard remember to take x as a float value!! apply the formula and be careful about the parantheses. happy programming!!!
#include<stdio.h>
#include<math.h>
void main()
{
float pow = 2.0, nr, dr = 1.0, x1, sum;
int i = 1,n,s = -1,x;
clrscr();
printf("\n\n\t ENTER THE ANGLE...: ");
scanf("%d", &x);
x1 = 3.142 * (x / 180.0);
sum = 1.0;
nr = x1*x1;
printf("\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d",&n);
while(i<=n)
{
dr = dr * pow * (pow - 1.0);
sum = sum + (nr / (dr * s));
s = s * (-1);
pow = pow + 2.0;
nr = nr * x1 * x1;
i++;
}
printf("\n\t THE SUM OF THE COS SERIES IS..: %0.3f", sum);
getch();
}
just get away
//WAP to print fibonacci series using do-while loop.? using System; class Fibonacci { public static void Main() { int a=1,b=1; int sum=0; Console.Write("Enter Limit:"); int n=Int32.Parse(Console.ReadLine()); Console.Write(a); Console.Write(b); do { sum=a+b; a=b; b=sum; Console.Write(sum); } while(sum<n); } } By-Vivek Kumar Keshari
#include using std::cin;using std::cout;using std::endl;int main(){int number1 = 73;int number2 = 415;int sum = 0;for (int i = number1; i
The name of the program. For example: program sum ! This is a comment. Your program's code goes here... end program sum
if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;
#include <iostream> using namespace std; int main() { int i,sum; // variables sum = 0; // initialize sum /* recursive addition of squares */ for (i = 1; i <= 30; i++) sum = sum + (i * i); cout << sum <<" is the sum of the first 30 squares." << endl; return 0; }
What is the assembly program to generate a geometric series and compute its sum The inputs are the base root and the length of the series The outputs are the series elements and their sum?
The geometric series is, itself, a sum of a geometric progression. The sum of an infinite geometric sequence exists if the common ratio has an absolute value which is less than 1, and not if it is 1 or greater.
It depends on the series.
The sum of the series a + ar + ar2 + ... is a/(1 - r) for |r| < 1
your face thermlscghe eugbcrubah
The sum to infinity of a geometric series is given by the formula Sā=a1/(1-r), where a1 is the first term in the series and r is found by dividing any term by the term immediately before it.
1/8
-20
Eight. (8)
No.
The geometric sequence with three terms with a sum of nine and the sum to infinity of 8 is -9,-18, and 36. The first term is -9 and the common ratio is -2.
sample program in sum of the series using the formula for s=n/2[2a+{n-1}d] in 8085