training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

creditlimit.c (765B)


      1 /* Esercizio 4.17 */
      2 
      3 #include <stdio.h>
      4 
      5 int main()
      6 {
      7    int i, account;
      8    float c_limit, c_saldo;
      9 
     10    for (i = 1; i <= 3; ++i) {
     11       printf("Account number: ");
     12       scanf("%d", &account);
     13       printf("Current credit limit: ");
     14       scanf("%f", &c_limit);
     15       printf("Current credit: ");
     16       scanf("%f", &c_saldo);
     17     
     18       printf("\n------------------------\n");
     19       printf("Account number: %d\n", account);
     20       printf("New credit limit: %.2f\n", c_limit /= 2);
     21       printf("Current credit: %.2f\n", c_saldo);
     22       printf("------------------------\n");
     23 
     24       if ((int) c_saldo > c_limit) {
     25 	 printf("* You are out of limit!\n");
     26          printf("------------------------\n");
     27       }
     28        printf("\n");
     29 
     30    }
     31 
     32    return 0;
     33 } /* E0F main */
     34