#include<iostream.h>
#include<conio.h>
int hcf(int,int);
void main()
{ clrscr();
int a,b;
cout<<"enter the numbers:";
cin>>a>>b;
cout<<"HCF of two number is:"<<hcf(a,b);
getch();
}
int hcf(int x,int y)
{
if(x>y)
{ for(int i=y;i>0;i--)
{ if(x%i==0&&y%i==0)
return i;
}
}
else
for(int i=x;i>0;i--)
{ if(x%i==0&&y%i==0)
return i;
}
}
- Upinder Singh Dhami
- Bangalore, Karnataka, India
- Extending one hand to help someone has more value rather than joining two hands for prayer
write a program which takes a number and return the sum of its digits using function
Tuesday, September 1, 2009Posted by Upinder Singh Dhami at Tuesday, September 01, 2009 0 comments
Labels: programs of function
find hcf using function
#include<iostream.h>
#include<conio.h>
int hcf(int,int);
void main()
{ clrscr();
int a,b;
cout<<"enter the numbers:";
cin>>a>>b;
cout<<"HCF of two number is:"<<hcf(a,b);
getch();
}
int hcf(int x,int y)
{
if(x>y)
{ for(int i=y;i>0;i--)
{ if(x%i==0&&y%i==0)
return i;
}
}
else
for(int i=x;i>0;i--)
{ if(x%i==0&&y%i==0)
return i;
}
}
Posted by Upinder Singh Dhami at Tuesday, September 01, 2009 0 comments
Labels: programs of function
basic of function
#include<stdio.h>
#include<conio.h>
void mon();
void sat();
void main()
{
clrscr();
sat();
sat();
sat();
mon();
getch();
}
void mon()
{
sat();
}
void sat()
{
static int i;
printf("\n%d",i);
i++;
}
Posted by Upinder Singh Dhami at Tuesday, September 01, 2009 0 comments
Labels: programs of function