-
Notifications
You must be signed in to change notification settings - Fork 0
/
ass5_15CS30043_test2.c
95 lines (89 loc) · 1.88 KB
/
ass5_15CS30043_test2.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//Testing Recursive calls and other basic operations on data types
int printInt(int n);
int readInt(int* n);
int printStr(char* str);
int readFlt(double* f);
int printFlt(double f);
int fact(int a)
{
if(a==1)
return 1;
else
return a*fact(a-1);
}
int sum(int a, int b)
{
int c;
c = a+b;
return c;
}
char sumchar(char a, char b)
{
char c;
c = a+b;
return c;
}
void main(){
int m,n,c;
int i;
i = printStr("Enter an integer M:\n");
i = readInt(&m);
i = printStr("Enter an integer n:\n");
i = readInt(&n);
c = sum(n,m);
i = printStr("Sum of the two integers :\n");
i = printInt(c);
i = printStr("\n");
i = printStr("Difference of the two integers :\n");
c = m-n;
i=printInt(c);
i = printStr("\n");
i = printStr("Product of the two integers :\n");
c = m*n;
i=printInt(c);
i = printStr("\n");
i = printStr("Quotient of the two integers :\n");
c = m/n;
i=printInt(c);
i = printStr("\n");
i = printStr("Remainder of the two integers :\n");
c = m%n;
i=printInt(c);
i = printStr("\n");
i = printStr("Factorial of M :\n");
c = fact(m);
i=printInt(c);
i = printStr("\n");
i = printStr("Factorial of N :\n");
c = fact(n);
i=printInt(c);
i = printStr("\n");
char schar2 = 'a';
char schar3 = 'b';
char schar = sumchar(schar2,schar3);
double x,y,z;
i = printStr("Enter an double X:\n");
i = readFlt(&x);
i = printStr("Enter an double Y:\n");
i = readFlt(&y);
i = printStr("Sum of the two doubles :\n");
z = x+y;
i=printFlt(z);
i = printStr("\n");
i = printStr("Difference of the two doubles :\n");
z = x-y;
i=printFlt(z);
i = printStr("\n");
i = printStr("Product of the two doubles :\n");
z = x*y;
i=printFlt(z);
i = printStr("\n");
i = printStr("Division of the two doubles :\n");
z = x/y;
i=printFlt(z);
i = printStr("\n");
//char schar,schar2,schar3;
//int d = fact(5);
//int k=printInt(d);
return;
}