A certain grade of steel is graded according to following condition: (i) Hardness must be greater than 50. (ii)carbon content must be less than 0.7 (iii)Tensile strength must be greater than 5600. the grades as follows: grade is 10 if all three condition are met, Gradeis 9 if conditions (i)and (ii) are met , Grade is 8 if condition (ii) and (iii) are met , Grade is 7 if condition (i) and (iii) are met, Grade is 6 if only one condition is met , Grade is 5 if none of the conditions are met . write a program which will require the user to give values of hardness , carbon content and tensile stength of the steel under consideration and output the grade of steel
A certain grade of steel is graded according to following condition:
(i) Hardness must be greater than 50.
(ii) carbon content must be less than 0.7
(iii)Tensile strength must be greater than 5600.
the grades as follows:
grade is 10 if all three condition are met,
Grade is 9 if conditions (i)and (ii) are met ,
Grade is 8 if condition (ii) and (iii) are met ,
Grade is 7 if condition (i) and (iii) are met,
Grade is 6 if only one condition is met ,
Grade is 5 if none of the conditions are met .
write a program which will require the user to give values of hardness , carbon content and tensile strength of the steel under consideration and output the grade of steel
#include<stdio.h>
#include<conio.h>
int main()
{
//h=hardness of steel
// c= carbon content
//ts=Tensile strength
float h,cc, ts;
//flag for three condition
int h_f =0,cc_f=0,ts_f=0;
//is 0 represent fales and one represent for true
int grade;
printf("Enter the value of hardness:");
scanf("%f",&h);
printf("Enter the value of carbon content:");
scanf("%f",&cc);
printf("Enter the value of tensile strength:");
scanf("%f",&ts);
//for finding grade
//1 if none of the condition is met
if(h_f==1||cc_f==1||st_f==1)
grade=5;
//2 if only one condition are met
if(h_f==1||cc_f==1||ts==1)
grade =6;
//3 if condition (i) and (iii) are met
if(h_f==1||cc_f==1&&ts_f==1)
grade 7 ;
//4 if condition (ii) and (iii) are met
if(h_f==1||cc_f==1&&ts_f==1)
grade 8;
//5 if condition (i) and (iii) are met
if(h_f==1||cc_f==1&&ts_f==0)
grade 9;
//4 if condition (ii) and (iii) are met
if(h_f==1&&cc_f==1&& ts_f==1)
grade 10;
printf("The grade of steel is :%d ",grade);
}
output-- Enter the value of hardness:60
Enter the value of carbon content:0.6
Enter the value of tensile strength:5800
The grade of steel is:10
related question-
Comments
Post a Comment