-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypeoffuntion.c
More file actions
45 lines (32 loc) · 824 Bytes
/
typeoffuntion.c
File metadata and controls
45 lines (32 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Types of Functions:
Implement a function calculateSquare that takes an integer as a parameter and returns its square.
Implement a recursive function to calculate the factorial of a no.
*/
#include <stdio.h>
int factorial = 1;
int factorialof(int n);
int squarenum(int num);
int main(){
int num;
printf("Enetr the number : ");
scanf("%d",&num);
int Square_result = squarenum(num);
printf("\nThe Square of the number is : %d ",Square_result);
int factorial_result = factorialof(num);
printf("\nThe Factorial of %d is : %d ",num,factorial_result);
return 0;
}
int squarenum(int num){
int Square ;
Square = num*num;
return Square;
}
int factorialof(int n){
if(n<1){
return factorial;
}
else{
factorial = n*factorialof(n-1);
}
}