while döngüsüne yerleştirilmiş switch () işinizi görecektir.

kolaygelsin

papatya prenses wrote:
merhaba iyi günler. aşağıdaki bir programın 3. seçeneği aşağıdaki şekilde olacak ama bu çok uzun oldu. bunu daha kısa nasıl yazabilirm?
 
ÇIKTI ÖRNEĞİ:
 

"

Min grade: 45

You received this grade in Quiz3

 

Max grade: 90

You received this grade in Midterm1

"

 
PROGRAM:
 
if(choice==3)
    {
       max=final;
       min=final;
      
      
       if(max<midterm1)
          max=midterm1;
          
                 
       if(max<midterm2)  
          max=midterm2;
         
      
       if(max<quiz1)
          max=quiz1;
      
       if(max<quiz2)
          max=quiz2;
      
       if(max<quiz3)
          max=quiz3;
   
       printf("\nMax grade:%d\n",max);
      
       if(max==final)
       printf("You received this grade in Final.\n");
      
       if(max==midterm1)
          printf("You received this grade in First Midterm.\n");
          
       if(max==midterm2)
       printf("You received this grade in Second Midterm.\n");
      
       if(max==quiz1)
       printf("You received this grade in First Quiz.\n");
      
       if(max==quiz2)
       printf("You received this grade in Second Quiz.\n");
      
       if(max==quiz3)
       printf("You received this grade in Third Quiz.\n");
   
       if(min>midterm1)
          min=midterm1;
      
       if(min>midterm2)  
          min=midterm2;
      
       if(min>quiz1)
          min=quiz1;
      
       if(min>quiz2)
          min=quiz2;
      
       if(min>quiz3)
          min=quiz3;
   
       printf("\nMin grade:%d\n",min);
      
       if(min==final)
       printf("You received this grade in Final.\n");
      
       if(min==midterm1)
       printf("You received this grade in First Midterm.\n");
      
       if(min==midterm2)
       printf("You received this grade in Second Midterm.\n");
      
       if(min==quiz1)
       printf("You received this grade in First Quiz.\n");
      
       if(min==quiz2)
       printf("You received this grade in Second Quiz.\n");
      
       if(min==quiz3)
       printf("You received this grade in Third Quiz.\n");
      
      
    }
 
teşekkür ederim. iyi günler.

_______________________________________________ Linux-programlama mailing list [email protected] http://liste.linux.org.tr/mailman/listinfo/linux-programlama


_______________________________________________
Linux-programlama mailing list
[email protected]
http://liste.linux.org.tr/mailman/listinfo/linux-programlama

Cevap