Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int cond_1=0, cond_2=0, cond_3=0, total_cond=0;
- float hardness, carbon, tensile;
- printf("Hardness: ");
- scanf("%f", &hardness);
- printf("Carbon content: ");
- scanf("%f", &carbon);
- printf("Tensile strength: ");
- scanf("%f", &tensile);
- if(hardness>60.0){ //Checking Conditions
- cond_1 = 1;
- total_cond++;
- }
- if(carbon<0.7){
- cond_2 = 1;
- total_cond++;
- }
- if(tensile>5000.0){
- cond_3 = 1;
- total_cond++;
- }
- printf("\n");
- printf("%f \n %f \n %f \n", hardness,carbon,tensile);
- printf("\n");
- if(cond_1 && cond_2 && cond_3){
- printf("Grade is 10");
- }
- else if(cond_1 && cond_2){
- printf("Grade is 9");
- }
- else if(cond_2 && cond_3){
- printf("Grade is 8");
- }
- else if(cond_1 && cond_3){
- printf("Grade is 7");
- }
- else if(total_cond==1){
- printf("Grade is 6");
- }
- else if(total_cond==0){
- printf("Grade is 5");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement