Problem 77. C Program to print a frequency distribution table for a class of 20-students in the following format. The marks range form 1-25.
class intertval frequency
1.5 1-5
6.10 6-10
11.15 11-15
16.20 16-20
21.25 21-25
#include<stdio.h>
#include<conio.h>
main( )
{
int a[20],i,n1=0,n2=0,n3=0,n4=0,n5=0;
clrscr();
printf(“enter the any 20 no of range(1- 25));
for(i=1;i<=20;i++)
scanf(“%d”,&a[i]);
for(i=1;i<=20;i++)
if((a[i]>=1)&&(a[i]<6))
n1++;
else
if((a[i]>5)&&(a[i]<11))
n2++;
else
if((a[i]>10)&&(a[i]<16))
n3++;
else
if((a[i]>15)&&(a[i]<21))
n4++;
else
if((a[i]>20)&&(a[i]<26))
n5++;
printf(“class interval frequency”);
printf(“n 1-5 %d”,n1);
printf(“n 6-10 %d”,n2);
printf(“n 11-15 %d”,n3);
printf(“n 16-20 %d”,n4);
printf(“n 21-25 %d”,n5);
getch();
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignmentclass intertval frequency
1.5 1-5
6.10 6-10
11.15 11-15
16.20 16-20
21.25 21-25
#include<stdio.h>
#include<conio.h>
main( )
{
int a[20],i,n1=0,n2=0,n3=0,n4=0,n5=0;
clrscr();
printf(“enter the any 20 no of range(1- 25));
for(i=1;i<=20;i++)
scanf(“%d”,&a[i]);
for(i=1;i<=20;i++)
if((a[i]>=1)&&(a[i]<6))
n1++;
else
if((a[i]>5)&&(a[i]<11))
n2++;
else
if((a[i]>10)&&(a[i]<16))
n3++;
else
if((a[i]>15)&&(a[i]<21))
n4++;
else
if((a[i]>20)&&(a[i]<26))
n5++;
printf(“class interval frequency”);
printf(“n 1-5 %d”,n1);
printf(“n 6-10 %d”,n2);
printf(“n 11-15 %d”,n3);
printf(“n 16-20 %d”,n4);
printf(“n 21-25 %d”,n5);
getch();
}
C compiler: gcc 4.1.2