blob: 3cbb2eec8a9a5c6cb2ad8cc2c5f6ed5e33d2b3fb (
plain)
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
|
// Case Study:-Chapter 6
// 2.Histogram
N=5;
for n=1:N
printf("Enter employees in Group-%d:",n);
value(n)=scanf("%d"); //Read data in the array named value
printf("%d\n",value(n)); //Print number which is at position n
end
printf("\n");
printf(" |\n");
//Computation using for loop and draw a histogram
for n=1:N
for i=1:3
if(i==2) then
printf("Group-%1d |",n);
else
printf(" |");
end
for j=1:value(n)
printf("*");
end
if(i==2)
printf("(%d)\n",value(n));
else
printf("\n");
end
end
printf(" |\n");
end
|