-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3
113 lines (84 loc) · 1.73 KB
/
day3
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
1:-Write a program to get two integers from the user and print the sum of the two integers?
#include<stdio.h>
void main()
{
int a,b;
printf("enter two numbers:");
scanf("%d%d",&a,&b);
printf("the sum of two numbers:%d",(a+b));
}
2:-Write a function to add two integers.
#include<stdio.h>
int sum(int a, int b);
void main()
{
int a,b,add;
printf("\n enter the numbers:");
scanf("%d%d",&a,&b);
add=sum(a,b);
printf("sum=%d",add);
}
3:-Write a program to get two float from the user and print the sum of the two float?
#include<stdio.h>
void main()
{
float a,b;
printf("enter two numbers:");
scanf("%f%f",&a,&b);
printf("%f",a+b);
}
4:-Write a function to add two float.
#include<stdio.h>
float sum(float a,float b);
void main()
{
float a,b,add;
printf("enter the numbers:");
scanf("%f%f",&a,&b);
add=sum(a,b);
printf("total=%f",add);
}
float sum(float a,float b)
{
float result;
result=a+b;
return result;
}
5:-Write a function to compare 2 numbers and test it.
#include<stdio.h>
int compare(int a,int b);
void main()
{
int a,b,large;
printf("enter the numbers:");
scanf("%d%d",&a,&b);
large=compare(a,b);
printf("largest=%d",large);
}
int compare(int a,int b)
{
if(a>b)
return a;
else
return b;
}
6:-Write a function to compare 3 numbers and test it.
#include<stdio.h>
int compare(int a,int b,int c);
void main()
{
int a,b,c,large;
printf("enter the numbers:");
scanf("%d%d%d",&a,&b,&c);
large=compare(a,b,c);
printf("largest=%d",large);
}
int compare(int a,int b,int c)
{
if(a>b && a>c)
return a;
if(b>a && b>c)
return b;
else
return c;
}