library functions (eg. main) and user defined functions (eg. printf,scanf)
In order to make user defined functions need three elements that are
related to functions
i) functions Definition
ii) functions Call
iii) functions declaration
CATEGORY OF FUCTIONS
Functions, depending on whether arguments are present or not and whether a
value is returned or not may belong to one of the following categories
CATEGORY 1:-
OUTPUT:-
Enter two numbers:2 3
Addition two no is 5
NOTE:-Function sum() is used for asking user a input, for
addition. No argument is passed and returned from sum().
CATEGORY 2:-
{
Int I,flag=1;
For(i=1;i<=num;i++)
{
Flag=flag*i;
}
Printf(“factorial is %d”,flag);
}
OUTPUT:-
Enter anynumbers:2
Factorial is 2
#include <stdio.h>
#include<conio.h>
{ / / no argument is passed
Int ans;
Clrscr();
Ans=factorial();
Printf(“factorial is %d”,ans);
Getch();
Int I,fact=1,num;
Scanf(“%d”,&num);
For(i=1;i<=num;i++)
{
Fact=fact*i;
}
Return (fact);
}
OUTPUT:-
Enter any numbers:2
Factorial is 2
CATEGORY 4:-
Ans=factorial();
Printf(“factorial is %d”,ans);
Getch();
}
Int i,fact=1,;
For(i=1;i<=num;i++)
{
Fact=fact*i;
}
Return (fact);
OUTPUT:-
Enter any numbers:2
Factorial is 2