
cin>>y;
cout<<“\nSum of Fibonacci numbers upto ”<<y<<“ is ”<<a.fib(y);
getch();
return 0;
}
Output:
Enter the number:7
Sum of Fibonacci numbers upto 7 is 13
SUMMARY
(1) A class in C++ is similar to structure
in C. Using class or structure, a pro-
grammer can merge one or more dissim-
ilar data types and a new custom data
type can be created.
(2) In C++, classes and structures contain
member variables and member func-
tions in their declarations with pri-
vate and public access blocks that
restrict the unauthorized use. The de-
fined classes and structures further can
be used as custom data type in the pro-
gram to declare objects. ...