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?
1
Expert's answer
2012-10-25T11:55:14-0400
#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(); }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment