License, disclaimer of liability, and limited warranty


Example  8: Write a C program to process student records using



Download 2,08 Mb.
Pdf ko'rish
bet360/393
Sana05.01.2022
Hajmi2,08 Mb.
#319699
1   ...   356   357   358   359   360   361   362   363   ...   393
Bog'liq
C Programming A Self Teaching Int 1uq45XL

Example
 8: Write a C program to process student records using
 
structures.
Solution 8:
 The program is as follows:
#include
main( )
 {
   struct record
    {
      char name[30];
      char regno[12];
      float avg;
      int rank;
    } student[50], temp;
 
    int i, j, n;
    printf(“\n Processing student %d record…\n”, i+1);
    printf(“Student name? (type END to terminate) “);
    scanf(“%s”, student[i].name);
    printf(“%s\n”, student[i].name);
      while (strcmp(student[i].name, “END”) > 0)


       {
         printf(“Register number? “);
         scanf(“%s”, student[i].regno);
         printf(“%s\n”, student[i].regno);
         printf(“Average marks? “);
         scanf(“%f”, &student[i].avg);
         printf(“%f\n”, student[i].avg);
         i++;
         printf(“\n Processing student %d record…\n”, i+1);
         printf(“Student name? (type END to terminate) “);
         scanf(“%s”, student[i].name);
         printf(“%s\n”, student[i].name);
       }
      n = i;
      /* arranging student marks */
      for (i=0;i         for (j = i+1; j          {
            if (student[i].avg < student[j].avg)
             {
                  temp = student[i];
                  student[i] = student[j];
                  student[j] = temp;
             }
          }
      /* Storing ranks */
      for (i=0;i         student[i].rank = i+1;
 
      /* Displaying records of students */
      printf(“\n\n Student records after giving them ranks:\n”);
      printf(“\n”);
      printf(“ NAME REGISTER_NUMBER AVERAGE RANK\n”);
      prin tf(“--------------------------------------------------------------
-----------------\n“);
      for (i=0; i       {
         printf(“% -20s 5 -10s”, student[i].name, student[i].    regno);
         printf(:%10.2f %d \n”, student[i].avg, student[i].rank);
       }
 }

Download 2,08 Mb.

Do'stlaringiz bilan baham:
1   ...   356   357   358   359   360   361   362   363   ...   393




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish