Advertisement
Naim19149

Grade_of_steel

Feb 21st, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include  <stdio.h>
  2.  
  3. int main(){
  4.     int cond_1=0, cond_2=0, cond_3=0, total_cond=0;
  5.  
  6.     float hardness, carbon, tensile;
  7.  
  8.     printf("Hardness: ");
  9.     scanf("%f", &hardness);
  10.     printf("Carbon content: ");
  11.     scanf("%f", &carbon);
  12.     printf("Tensile strength: ");
  13.     scanf("%f", &tensile);
  14.  
  15.     if(hardness>60.0){  //Checking Conditions
  16.         cond_1 = 1;
  17.         total_cond++;
  18.     }
  19.     if(carbon<0.7){
  20.         cond_2 = 1;
  21.         total_cond++;
  22.     }
  23.     if(tensile>5000.0){
  24.         cond_3 = 1;
  25.         total_cond++;
  26.     }
  27.  
  28.     printf("\n");
  29.  
  30.     printf("%f \n %f \n %f \n", hardness,carbon,tensile);
  31.  
  32.     printf("\n");
  33.  
  34.     if(cond_1 && cond_2 && cond_3){
  35.         printf("Grade is 10");
  36.     }
  37.     else if(cond_1 && cond_2){
  38.         printf("Grade is 9");
  39.     }
  40.     else if(cond_2 && cond_3){
  41.         printf("Grade is 8");
  42.     }
  43.     else if(cond_1 && cond_3){
  44.         printf("Grade is 7");
  45.     }
  46.     else if(total_cond==1){
  47.         printf("Grade is 6");
  48.     }
  49.     else if(total_cond==0){
  50.         printf("Grade is 5");
  51.     }
  52.  
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement