Friday, October 22, 2010

#3 Switch Operator višestrukog grananja opisne ocene zaokruzivanje

#include<conio.h>
#include<math.h>
 main()
{
       int ocena;
       float ocenaf;
    printf("---------------------------- Operatori visestrukog grananja SWITCH ------------------------------------------------\n\n");
    printf("Switch operator zamenjuje visestruki if \n\n");
    printf("Program za prikazivanje celih skolskih ocena opisno (1:nedovoljan, 2:dovoljan, 3:dobar, 4:vrlodobar, 5:odlican) \n\n");
    printf("Unesite vasu prosecnu ocenu kao ceo broj npr. 2.5=3 4,2=4 ... \n");
    printf("ocenaf="); scanf("%f",&ocenaf);
    ocena=ceil(ocenaf);
    switch (ocena){
           case 1:
                {
                 printf("\n Nedovoljan");
                 break;                     
                }
           case 2:
                 {
                 printf("\n Dovoljan");
                 break;                     
                }
            case 3:
                 {
                 printf("\n Dobar");
                 break;                     
                }
             case 4:
                 {
                 printf("\n Vrlodobar");
                 break;                     
                }
              case 5:
                 {
                 printf("\n Odlican");
                 break;                     
                }
              default:
                {
                printf("\n Uneli ste nedefinisanu ocenu u mom sistemu");     
                break;
                }   
              }
              getch();
     }

No comments:

Post a Comment