Browsing articles in "C++"
Dec
3

Object & Methods in C++

By admin  //  C++  //  View Comments

#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);
}

Oct
5

Recusive Function in C++

By admin  //  C++  //  View Comments

#include<iostream.h>
#include<conio.h>
int fact (int num);
void main()
{
int x;
cout<<”Enter a number”<<endl;
cin>>x;
cout<<fact(x);
getch();
}
int fact(int num)
{
int y;
if(num==0)
y=1;
else
y= num * fact(num-1);
return(y);
}

Namaste!

Hello! This is Nirmal Gyanwali, a freelance web developer from Kathmandu, Nepal. I am well versed with Open source CMS and portal frameworks like Joomla!, Wordpress, Drupal. If you're interested, you can contact me at info@nirmal.com.np.
Thanks!

Latest Tweets