Watching Sky

Database

  • C
  • BASIC
C

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i,j;
 long int s[100];
 float a[100][4],ap[100][4],ao[100]={0},c[4]={0};
 clrscr();
 printf("STUDENT ATTENDANCE RECORDS\n\n");
 printf("Enter the no. of students in the class: ");
 scanf("%d",&n);
 printf("\nEnter the 7-digit reg no. of the %d students in ascending order:\n",n);
 for(i=0;i<n;i++) scanf("%ld",&s[i]);
 printf("\nEnter the no. of hours held in this month\n");
 for(j=0;j<4;j++)
 {
  printf("for Subject%d: ",j+1);
  scanf("%f",&c[j]);
 }
 printf("\nEnter classes (no. of hours) attended\n");
 for(i=0;i<n;i++)
 {
  printf("\nby %ld\n",s[i]);
  {
  for(j=0;j<4;j++)
  { printf("in Subject%d: ",j+1); scanf("%f",&a[i][j]); }
  }
  printf("\n");
 }
 printf("ATTENDANCE PERCENTAGE\n\n");
 printf("Reg No. | Subject1 | Subject2 | Subject3 | Subject4 | Overall\n\n");
 for(i=0;i<n;i++)
 {
  for(j=0;j<4;j++) { ap[i][j]=100*a[i][j]/c[j]; ao[i]+=ap[i][j]; }
  ao[i]=ao[i]/4;
  printf("%ld -> %6.2f  |  %6.2f  |  %6.2f  |  %6.2f  |  %6.2f\n",
    s[i],ap[i][0],ap[i][1],ap[i][2],ap[i][3],ao[i]);
 }
 getch();
}

BASIC