-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCode.html
100 lines (96 loc) · 4.13 KB
/
Code.html
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
<!DOCTYPE html>
<html>
<head>
<title>CODE</title>
</head>
<body>
<header>
<h1 style="text-align: center;">C PROGRAMS</h1>
</header>
<hr>
<div>
<div>
<h2>PROBLEM STATEMENT</h2>
<h3>
Write a program in any language to read 10 numbers from keyboard and find their sum and average.
</h3>
<h4>C Code:</h4>
<pre>
<code>
#include <stdio.h>
void main()
{
int i,n,sum=0;
float avg;
printf("Input the 10 numbers : \n");
for (i=1;i<=10;i++)
{
printf("Number-%d :",i);
scanf("%d",&n);
sum +=n;
}
avg=sum/10.0;
printf("The sum of 10 no is : %d\nThe Average is : %f\n",sum,avg);
}
</code>
</pre>
</div>
<hr>
<div>
<h4>Sample Input & Output</h4>
<p>
Input the 10 numbers : <br>
Number-1 :<kbd>1</kbd> <br>
Number-2 :<kbd>2</kbd> <br>
Number-3 :<kbd>3</kbd> <br>
Number-4 :<kbd>4 </kbd> <br> Number-5 :<kbd>5 </kbd> <br>
Number-6 :<kbd>6</kbd> <br>
Number-7 :<kbd>7</kbd> <br>
Number-8 :<kbd>8</kbd> <br>
Number-9 :<kbd>9</kbd> <br>
Number-10 :<kbd>10</kbd> <br>
The sum of 10 no is :<samp>55</samp> <br>
The Average is :<samp> 5.500000 </samp><br>
</p>
</div>
<hr>
<div>
<h4>Variable used</h4>
<p>
The variables used in this program are:
<br>
int variables: <var>i</var>, <var>n</var> , <var>sum</var>
<br>
float variables: <var>avg</var>
<br>
</p>
</div>
<hr>
<div>
<h3>Complexity</h3>
<p>
Complexity for this program is: O(n)
</p>
</div>
<hr>
<div>
<p>
Refer link for algorithm:<a href="https://www.w3resource.com/c-programming-exercises/for-loop/c-for-loop-exercises-4.php">Algorithm</a>
</p>
<hr>
<p>
<small>Sorting algorithms:</small>
<br>
1.Selection sort: Complexity is O(n<sup>2</sup>)
<br>
2.Merge Sort: complexity is O(nlog<sub>2</sub>n)
<br><s>complexity is O(n)</s>
</p>
</div>
<hr>
</div>
<footer style="text-align: center;">
<p><small>Code is taken from another website</small></p>
</footer>
</body>
</html>