3
Object & Methods in C++
#include<iostream.h>
#include<conio.h>
class employee
{
char name[30];
int age;
public:
void getdata(void);
void putdata(void);
};void employee::getdata(void)
{
cout<<”Enter name and age”<<endl;
cin>>name>>age;
}void employee::putdata(void)
{
cout<<”Name: “<<name<<endl;
cout<<”Age : “<<age<<endl;
}const int size=3;
int main()
{
employee emp[size];
for(int i=0;i<3;i++)
{
cout<<”Details of “<<i+1<< “employee:\n”;
emp[i].getdata();
}
cout<<endl<<endl;
cout<<”The details are:”<<endl;
for(i=0;i<3;i++)
{
cout<<”Employee No.:”<<i+1<<endl;
emp[i].putdata();
cout<<endl;
}
getch();
return(0);
}
5
Fibonacci Series In C++
# include <iostream.h>
# include <conio.h>
void main()
{
int i,j,k,n;
clrscr();
cout<<”Enter The Numbers Of Numbers To Be Printed In The Series”<<endl;
cin>>n;
i=0;
j=1;
cout<<i<<endl;
cout<<j<<endl;
while(n>2)
{
k=i+j;
i=j;
j=k;
cout<<k<<endl;
n=n-1;
}
getch();
}
Output: 0,1, 1, 3, 5, 8, 13……
Namaste!
Recent Posts
Tags
Latest Tweets
- You can't beat that!!! ha ha ha ha
http://t.co/RncN75Qy - posted on 18/05/2012 08:51:10 - Would you do these workouts -- at work? http://t.co/9FjVfJZ2 - posted on 18/05/2012 08:46:13
- Congratulations didi n Vinaju! http://t.co/tgWnJQ7l - posted on 18/05/2012 06:04:54




