68 217
Assignments Done
98,9%
Successfully Done
In November 2018

Answer to Question #16983 in C++ for martin

Question #16983
How static variable is different from the simple class variable?
WAP to add first seven terms of the following series:
1/1! + 2/2! + 3/3! +........
Explain the effect of static variable on the output of the program?
Expert's answer

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
static int sum = 0;
int factorial = 1;

for(int i = 1; i < 7; i++)
{
& for(int j = 1; j < i;j++) {
& factorial +=j;
& }
& sum += i/factorial;
& factorial = 0;
}
cout << sum << endl;
_getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions