skip to main |
skip to sidebar
#include
#include
#define add(a,b) a+b //defining the macro
void main()
{
int x,y,sum;
clrscr();
printf("enter the 2 numbers for addition\n");
scanf("%d\n%d",&x,&y);
sum = add(x,y); //using it here
printf("\ntheir sum is %d",sum);
getch();
}
#include
#include
void main()
{
float fact(float),f;
clrscr();
printf("\nEnter the number whose factorial is to be found out\n");
scanf("%f",&f);
printf("\nThe factorial of %f is %f.",f,fact(f));
getch();
}
float fact(float no)
{
float factorial;
if(no==1)
return 1;
else
factorial=no*fact(no-1);
return factorial;
}