Paste Search Dynamic
core course
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int course_no = 0, lecthrs =0, tuthrs=0, prachrs=0, credits=0;
  5.     int totallh =0, totalth = 0, totalph = 0, totalcredits = 0, nlab = 0, ntheory = 0, nelec = 0, ncore = 0, nsa = 0;
  6.  
  7.     //Using do-while loop as code has to be executed atleast once
  8.     do{
  9.         scanf("%d %d %d %d %d", &course_no, &lecthrs, &tuthrs, &prachrs, &credits);
  10.         totallh += lecthrs;
  11.         totalth += tuthrs;
  12.         totalph += prachrs;
  13.         totalcredits += credits;
  14.  
  15.         if(course_no > 400){
  16.             //elective course
  17.             nsa++;
  18.         }
  19.         else {
  20.             //core courses
  21.             ncore++;
  22.             if (lecthrs == 0 && tuthrs >= 0 && prachrs > 0 && credits > 0){
  23.                 //lab courses
  24.                 nlab ++;
  25.             }
  26.             else if (lecthrs > 0 && tuthrs >= 0 && prachrs >= 0 && credits > 0){
  27.                 //theory courses
  28.                 ntheory ++;
  29.             }
  30.             else if (lecthrs >= 0 && tuthrs >= 0 && prachrs >= 0 && credits == 0){
  31.                 //SA courses
  32.                 nsa ++;
  33.                 totalph -= prachrs;
  34.             }
  35.         }
  36.  
  37.         //Printing all outputs
  38.         printf("1. Total number of lecture hours credited: %dn", totallh);
  39.         printf("2. Total number of tutorial hours credited: %dn", totalth);
  40.         printf("3. Total number of practical hours credited: %dn", totalph);
  41.         printf("4. Total number of credits registered: %dn", totalcredits);
  42.         printf("5. Number of lab courses registered: %dn", nlab);
  43.         printf("6. Number of theory courses registered: %dn", ntheory);
  44.         printf("7. Number of elective courses registered: %dn", nelec);
  45.         printf("8. Number of core courses: %dn", ncore);
  46.         printf("9. Number of SA courses: %dn", nsa);
  47.     }
  48.     while(course_no !=0 || lecthrs != 0 || tuthrs != 0 || prachrs != 0 || credits !=0);
  49. }
Parsed in 0.014 seconds